由买买提看人间百态

topics

全部话题 - 话题: idxdown
(共0页)
k***e
发帖数: 556
1
来自主题: JobHunting版 - 面试题
ok, my fault
i misunderstand the problem
suppose the problem is: given an array of pos ints, find a subseqence (may
not be continuous in the idxes), that is continuous integers that sum to a
certain value)
1) for each a[i] in the array, find idxUp > i such that a[idxUp] = a[i] + 1
idxDown < i such that a[idxDown] = a[i] - 1, note that the idxUp is the one
who is closest to i (similar to find idxDown)
2) thus from any idx, we know where is the next a[idx]+1, now we need to get
the length of the c
(共0页)