Skip to main content
The 2025 Developer Survey results are in. Explore insights into technology and tools, careers, community and more. View results.

All Questions

Filter by
Sorted by
Tagged with
4 votes
1 answer
2k views

Swift - Finding longest binary gap of a given integer

I recently had the chance to try Codility's algorithm training, and the very first one in the list is finding the longest binary gap of a given integer. I tried to implement this in Swift, and after ...
badhanganesh's user avatar
5 votes
2 answers
8k views

Find the number of K-Complementary pairs in an array

Below is the program to find k-complementary pairs: K = A[i] + A[j];. ...
SiddP's user avatar
  • 153
3 votes
3 answers
9k views

Intersection of subset between two lists of dicts

I want to find the intersection of two lists of dicts. Note that equality—i.e.: what is to appear in the intersection—is given by which keys they must have equal. See the ...
A T's user avatar
  • 535
2 votes
3 answers
2k views

Find intersection of two arrays without duplicates

A = [9, 1, 4, 2, 5] k unique integers B = [3, 1, 8, 7, 6, 5] n unique integers Intersection => [1, 5] Find an algorithm that uses \$O(1)\$ space (the space used by the return variable is not ...
Gqqnbig's user avatar
  • 131