algorithm Questions
3
Solved
I'm working on a small Python program for myself and I need an algorithm for fast multiplication of a huge array with prime powers (over 660 000 numbers, each is 7 digits). The result number is ove...
Constringe asked 15/7 at 23:55
28
So I was going through different sorting algorithms. But almost all the sorting algorithms require 2 loops to sort the array. The time complexity of Bubble sort & Insertion sort is O(n) for Bes...
Barrett asked 12/8, 2015 at 14:52
6
Solved
I need to create a binary bitmap from a closed 2D polygon represented as a list of points. Could you please point me to efficient and sufficiently simple algorithms to do that, or, even better, som...
Heliotaxis asked 27/8, 2009 at 14:13
12
Solved
I need to go from milliseconds to a tuple of (hour, minutes, seconds, milliseconds) representing the same amount of time. E.g.:
10799999ms = 2h 59m 59s 999ms
The following pseudo-code is the only...
Roush asked 3/6, 2012 at 21:22
5
Solved
What I mean by "large n" is something in the millions. p is prime.
I've tried
http://apps.topcoder.com/wiki/display/tc/SRM+467
But the function seems to be incorrect (I tested it with 144 choose 6...
Psi asked 12/4, 2012 at 5:57
2
Solved
I write two program :
put together n queens in chess board without any threatening by backtracking algorithm. but that is very heavy for big n . at last you can run that for 100 queens.
put toget...
Siegbahn asked 30/12, 2014 at 0:17
6
Solved
Let's say I have two arrays of the same length n, named A and B.
These two arrays contain real values.
We define the distance between two arrays as the mean squared distance.
dist(A,B) = sqrt( s...
Neptunian asked 4/1, 2019 at 14:59
6
Solved
Here is what I am using:
class something
{
char flags[26][80];
} a;
std::fill(&a.flags[0][0], &a.flags[0][0] + 26 * 80, 0);
(Update: I should have made it clear earlier that I am using t...
Tourane asked 16/10, 2010 at 9:14
7
Solved
I have a line segment defined by two pointFs, along with a 2D bounding rectangle. I want to extend the line segment as much as possible in both directions so that the segment is flush with the wall...
Nazarius asked 29/8, 2011 at 23:3
20
Solved
Not sure if I should've posted this on math.stackexchange instead, but it includes more programming so I posted it here.
The question seems really simple, but I've sat here for at least one hour n...
4
Solved
I have the following JavaScript object structure:
var options = {
optionOne: [true, false],
optionTwo: [true, false],
optionThree: [
null,
{property1: 9, property2: 7},
{property1: 4, proper...
Hispania asked 29/9, 2015 at 7:41
14
Solved
I'd like to break apart a String by a certain length variable.
It needs to bounds check so as not explode when the last section of string is not as long as or longer than the length. Looking for th...
3
Solved
Is there a simple way to take a list of numbers which can be in the range 1 - 15. And put a dash in place of consecutive numbers.
So that for example if you had the following numbers:
1 2 3 5 6...
6
A question that has me speculating is the following:
Let's say we have a sorted array with the numbers {1,1,1,1,2,2,4,4,4}.
Now, given that we can clearly see that we have six pairs on 1's, one p...
15
Solved
Design an efficient algorithm to sort 5 distinct - very large - keys less than 8 comparisons in the worst case. You can't use radix sort.
10
Solved
How can I get the number of "1"s in the binary representation of a number without actually converting and counting ?
e.g.
def number_of_ones(n):
# do something
# I want to MAKE this FASTER (co...
Ladida asked 9/5, 2009 at 18:54
3
Solved
Is it possible to calculate a SHA-1 hash in PowerShell V2.0?
The only information I can find online is with PowerShell V4.0.
Bernicebernie asked 1/12, 2014 at 15:55
40
Solved
Given a string S of length N find longest substring without repeating characters.
Example:
Input: "stackoverflow"
Output: "stackoverfl"
If there are two such candidates, return first from left...
19
Solved
This is one of the programming questions asked during written test from Microsoft. I am giving the question and the answer that I came up with. Thing is my answer although looks comprehensive (at l...
Travers asked 27/2, 2010 at 18:0
12
Solved
I want to sort items where the comparison is performed by humans:
Pictures
Priority of work items
...
For these tasks the number of comparisons is the limiting factor for performance.
What is...
9
Solved
Assuming there is a 1-D array/list which defines a color gradient I would like to use it in order to create a 2-D color gradient as follows:
Let's for simplicity replace color information with a si...
4
This should be an interresting challenge.
I'm looking for an algorithm that doesn't exist yet (to the best of my knowledge)
We have a database accessing function that can read pages of records at...
17
I have a question where I need to rotate an array left k times.
i.e. if k = 2, [1, 2, 3, 4, 5] . -> [3, 4, 5, 1, 2]
So, my code is:
def array_left_rotation(a, n, k):
for i in range(n):
t = a[i...
Sisyphus asked 24/3, 2018 at 7:8
4
Solved
I am using two arrays to accomplish a task of checking if values in array1 exist in array2. If so remove the content in array1 and keep checking till array1 is empty. If they dont exist just return...
Polyadelphous asked 3/4, 2014 at 21:29
8
Solved
Example:
WordDistanceFinder finder = new
WordDistanceFinder(Arrays.asList("the", "quick", "brown", "fox",
"quick"));
assert(finder.distance("...
© 2022 - 2024 — McMap. All rights reserved.