The 2024 Developer Survey results are live! See the results

# Tag Info

### Efficient polynomial multiplication in Python

I assumed the following modules were used: from math import ceil, log2, pi from cmath import exp I suggest the following changes for a 2x / 3x speedup (same time ...
• 916
1 vote

### Efficiently generate a random position inside an outer rectangle but outside an inner rectangle

The getRandomPoint does an unnecessary random. You could just adjust and pass your original random value into it and calculate the location. I.e. your first ...
• 21.7k
1 vote

### A simple performant factorial function

Performance. Your code is using a map in a very inefficient way. Poor use of a Map You have the line if(memos[num]) return memos[num]; This requires the ...
• 22.2k
1 vote

### Efficiently generate a random position inside an outer rectangle but outside an inner rectangle

I cannot find a superior algorithm than the one you have adopted to calculate this any faster. Essentially my idea was the same as yours: Identify four regions around the hole. Caluclate the area of ...
• 575
Accepted

### A simple performant factorial function

The function should hopefully run efficiently for calculating a very large number's factorial. Perhaps, but: you can take the factorial of 170, but after that the ...
• 10.2k
Accepted

### Speed up searching for the lowest element that is not in the array

You present code for a typical "challenge" submission without ever spelling out the problem in the source code. What's more, you miss the opportunity to declare a suggestively named business ...
• 6,529
Accepted

### A search function that searches for a contact inside a vector

Keeping in mind that it is impossible to give good answers, or a good review, without a clear context of what the code is for or how it is going to be used. A single member function—not even a full ...
• 12.1k
Accepted

### Optimized data structure mapping finite set of integers to values in C++

Design review You are massively over-complicating the problem You call it a map, and you talk about using integers as keys. But… in reality, because your keys are small, you are just using indices. So ...
• 12.1k