New answers tagged algorithm
5votes
Single Consumer Single Producer Wait-Free Zero-Copy Circular Message Queue
Be careful claiming it is wait-free You claim your queue is wait-free, but you have a potentially unbounded for-loop doing a compare-exchange operation. At the very ...
6votes
Single Consumer Single Producer Wait-Free Zero-Copy Circular Message Queue
design document We need to understand the constraints you're working within, so you should write them down. There are some comments in the implementation, which are helpful, but that's no substitute ...
2votes
Finding Special Parts in a Word
In such code, one should look for rules, smart logic. Here we have sequences x² and xyⁿx. (As already said in an earlier answer, with n = 0 one covers the first sequence.) The logic here is detecting ...
4votes
4votes
Finding Special Parts in a Word
The "length 2" rule is unnecessary, just ignore it and read the "length ≥ 3" rule as "length ≥ 2" instead. You can simplify your code accordingly, removing the ...
-2votes
Finding Special Parts in a Word
To reduce time complexity, we can avoid redundant substring operations and take advantage of string patterns. This strategy aims to solve the problem efficiently, with a time complexity closer to O(n²)...
3votes
Efficient way to win points in chocolate bowl game
The loop in skipsNeededToWin can take long. It has two phases: For some time, both you and your friend always take bites. After that, only you take bites, and your ...
1vote
Find max in-order difference in array
Layout Lines like this: if len(A)==1: return 0 are customarily split across 2 lines: if len(A)==1: return 0 The black ...
4votes
Accepted
bilateral_filter Template Function Implementation for Image in C++
Move padding out of bilateral_filter() Most of the code in bilateral_filter() is spent on managing a padded version of the input ...
1vote
Accepted
Dictionary based non-local mean implementation in Matlab
This function, dictionaryBasedNonlocalMean(), takes a "dictionary" of patches and an input patch, and returns the weighted mean of the dictionary patches. ...
Top 50 recent answers are included
Related Tags
algorithm × 5087java × 1283
python × 1203
performance × 1004
c++ × 847
programming-challenge × 658
javascript × 489
c# × 401
strings × 355
c × 332
python-3.x × 324
sorting × 320
beginner × 305
time-limit-exceeded × 251
graph × 250
array × 246
tree × 213
recursion × 177
interview-questions × 168
python-2.x × 163
complexity × 134
combinatorics × 132
mathematics × 108
c++11 × 102
matrix × 100