For the sliding window approach, if
xrange is changed to
range then it gets TLE. This is in Python2. Anybody have an idea why there is such a difference?
Posts made by yorkshire
RE: A Python binary search solution - O(logn)
@pythonyeh It returns the remainder from dividing
midis an index from 0 to
rows * cols - 1.
It finds the column index from the
mid = 30and
cols = 7refers to column index 2 (and
[mid / cols]refers to row index 4).
RE: Design Search Autocomplete System
@LArch I agree, none of the solutions feels efficient due to repeated sorting and storing duplicated copies of sentences.
How about storing all sentence in a map (sentence to count). Then for a new input create a list sorted by count and repeatedly filter as more chars are seen.
Better explanation and code ... https://discuss.leetcode.com/topic/112705/fast-and-simple-explained-no-trie-no-priority-queue