Search a string as you type the character

前端 未结 3 1419
日久生厌
日久生厌 2021-02-14 12:49

I have contacts stored in my mobile. Lets say my contacts are

Ram

Hello

Hi

Feat

Eat

At

When I type letter \'A\' I should get

3条回答
  •  日久生厌
    2021-02-14 13:24

    What I'm thinking to do is, keeping track of the so far matched string. Suppose in the first step, we identify the strings those have "A" in them and we keep trace of the positions of 'A". Then in the next step we only iterate over these strings and instead of searching them full we only check for occurrence of "T" as the next character to "A" we kept trace in the previous step and so on.

提交回复
热议问题