All Questions
7 questions
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 ...
2
votes
2
answers
2k
views
Determine if Array has an Increasing Sequence
I wrote a function in JavaScript that expects an array of integers (negative or positive) and determines if that array has an increasing sequence.
For the sake of better time performance I made the ...
2
votes
1
answer
1k
views
Find all pairs in an array whose absolute difference equals x
I have an array A of integers with n values and an integer x. I need to find all the pairs in that array whose absolute ...
4
votes
4
answers
1k
views
Find element that has been removed from a shuffled array
For a function to determine which element has been removed from a shuffled array, I came up with:
...
8
votes
2
answers
5k
views
Finding the count of negative sub-arrays for a given array
I want to improve my implementation for the following problem:
You are given an array of n integers. A sub-array is "Negative" if sum of all the integers in that ...
7
votes
2
answers
1k
views
Finding pairs of numbers within A that add up to N
I am working on an interview question from Amazon Software Interview:
Given an integer N and an array of unsorted integers A find all pairs of numbers within A which add up to N
I have a working ...
4
votes
3
answers
2k
views
Removing duplicates from an array
I recently wrote this JavaScript algorithm for removing duplicates from an array as part of a job interview process, but was turned down for the position after submitting the code. I didn't receive ...