Interview Question

Revision en3, by bablu_45, 2019-06-11 21:40:36

Given a 1-d array candy crush, return the shortest array after removing all the continuous same numbers (the no of occurences of repeating number >= 3)

input: 1-d array [1, 3, 3, 3, 2, 2, 2, 3, 1]

return: [1, 1] (Explanation:- 133322231->133331->11).

133322231->122231->131 gives answer as [131] which is not the shortest.

Time complexity should be better than O(n^2)

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en3 English bablu_45 2019-06-11 21:40:36 77
en2 English bablu_45 2019-06-11 21:30:32 22
en1 English bablu_45 2019-06-11 21:29:59 301 Initial revision (published)