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…

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…