-
Notifications
You must be signed in to change notification settings - Fork 62
Open
Description
Hello,
I think you can use a hash table to speed up the query.
- Create a hash table of words, with key values as characters, and values as positions of characters。
Word: Hello
User Input: eao

2)Find the character entered by the user: ‘e’,
Find by hash table, find the index greater than 0 (you can use binary search)。
The word index is at position 1.
- Find the character entered by the user: ‘a’,
Find by hash table, find index greater than 1 (you can use binary search)
'A' not found, index does not move
4)Find the character entered by the user: ‘o’,
Find by hash table, find the index greater than 0 (you can use binary search)。
The word index is at position 4.
I'm not familiar with js, I can't implement it with code, I'm really sorry.
Metadata
Metadata
Assignees
Labels
No labels