New answers tagged algorithm
0
votes
Create a snail matrix
Here is an alternative recursive implementation. It passes the OP's test code very well.
...
1
vote
3
votes
2
votes
Sanitize and standardize street addresses using Google Maps lookups
Layout
Move all the functions to the top after the import lines.
Having them in the middle of the code interrupts the natural
flow of the code (from a human ...
3
votes
Parse path string
Movement conflates at least three different things: tokenising/scanning (part of lexing), evaluating, and application of the path to start coordinates. In other ...
2
votes
Parse path string
Portability
I realize this question was posted many years ago when Python version 2.x
was prevalent, but now that it is deprecated, consider porting to 3.x.
To do so, it is necessary to add ...
3
votes
Hackerearth: Counting numbers in an array that are divisible by any 2 numbers
Always assume that coding challenge websites will give you worst case scenarios to test your code. They won't test your code with small arrays of small numbers. They'll give you large arrays with huge ...
1
vote
Hackerearth: Counting numbers in an array that are divisible by any 2 numbers
Portability
I realize this question was posted many years ago when Python version 2.x
was prevalent, but now that it is deprecated, consider porting to 3.x.
To do so, it is necessary to add ...
2
votes
Finding strings in a matrix
I think one of the biggest opportunities here is to make this more generic with the use of templates. We should be able to look for a sequence of values of any type in a vector of vectors.
A ...
2
votes
Inserting into a linked list
If we're assuming that head is not NULL, so let's split up the responsibilities: writing a separate function that finds the tail ...
5
votes
A Java program for compressing/decompressing files via Huffman algorithms (version 1.0.0)
Multiple aspects of this implementation of a Huffman encoder and decoder are inefficient.
At the top level, a bit-by-bit tree-walking decoder is inherently slow. Almost every practical decoder uses ...
2
votes
Binary Search Tree implementation in C [1]
Style
You mix braces and not using braces freely throughout your code. While this works, it leaves open the possibility of adding to branches of conditionals or to loops and forgetting to add braces, ...
3
votes
Huffman code builder in Java - computing prefix codes for arbitrary (generic) alphabets - Take II
The HuffmanEncoder is not an encoder. It's a builder that constructs the code table for the symbols based on the weights. An encoder would take input and encode it ...
4
votes
Shortest Cell Path In a given grid
Style
Let's look at this conditional in shortestCellPathHelper.
...
3
votes
HuffmannEncoder.java - computing prefix codes for arbitrary (generic) alphabets
Minor but, Huffman only has a single n in the name.
But let's move on to how the code words are built, the meat of the algorithm after all.
...
3
votes
HuffmannEncoder.java - computing prefix codes for arbitrary (generic) alphabets
Style
When I look at your formatting in the following snippet, for some reason you have a newline after the first argument to Double.compare, but this line would be ...
Top 50 recent answers are included
Related Tags
algorithm × 5127java × 1301
python × 1209
performance × 1013
c++ × 855
programming-challenge × 666
javascript × 488
c# × 401
strings × 359
c × 336
python-3.x × 324
sorting × 323
beginner × 306
graph × 260
time-limit-exceeded × 257
array × 249
tree × 213
recursion × 177
interview-questions × 169
python-2.x × 163
combinatorics × 134
complexity × 134
mathematics × 112
pathfinding × 103
c++11 × 101