MaxCounters Codility JAVA solution (100/100)

Ok, this is first interesting one. The concept goes like this. We iterate through input array and increase a value for element in counterArray. Elements in counterArray represents number of repetitions in inputArray of the value of index in counterArray. We intuitively iterate through inputArray until we get to element with value of N+1. Then reset Read More …

PermCheck Codility JAVA solution (100/100)

This task we can solve the similar way as PermMissingElem. First create an array of prefix sums and calculate the sum of elements in array and expected sum of elements. Subtracting those two gives the result.  


TapeEquilibrium Codility JAVA solution (100/100)

This task can be easily done with prefix sums. In first for loop we create the sumArray which contains sum of all elements from A[1] to A[i]. After that, we iterate through sumArray. In position i, the element sumArray[i] tells us sum of elements from A[1] to A[i] and if we do sumArray[lastElement] – sumArray[i] we Read More …

PermMissingElem Codility JAVA solution (100/100)

Since the numbers in array are starting from 1 we can get the sum of all elements in array and subtract it from expected sum of elements if there wasn’t missing any. That should give us the element missing.  


FrogJump Codility JAVA solution (100/100)

The frog wants to get on the other side of the road and she needs (y – x)/d jumps to get there. Simple as that. Since that can be decimal number we need to check if it needs to be rounded on lower or greater number. And that’s it. 🙂