Close

## Partial sum queries

Given an array of numbers, we need to answer many queries of the form Sum(A[i]…A[j]), For example, let the array be [15, 6, 1, 12, 7, 4, 10] Sum(A[1:3]) = 15+6+1 = 22 Sum(A[4:6]) = 12+7+4 = 23 … The simplest solution is to iterate through the elements from i to j and return the…

## Searching for an element in array of adjacent numbers

Given an array of numbers where the difference between any adjacent numbers is 1, how do we efficiently find a given number? For example consider the array {1, 2, 1, 2, 3, 2, 3, 4, 5, 6}, and we want to search for the number 5. The simplest solution is to check if the number…

## Check if a string is a double string

Given a string, we need to check if a string is a double string possibly by deleting a character. A double string is a repetition of two strings affixed together. For example the following strings are double strings “aa”, “meme”, “abbabb” Where as the follwing are not double strings “ab”, “abc”, “acbab” However “acbab” can…