Solve common string and subarray problems | LinkedIn Interview Question