Answer the question
In order to leave comments, you need to log in
What is the best way to search in an array?
There is an array var array = ['меню',...];
I need to find all elements starting with a string. Suppose for "a" all words starting with "a", then all beginning with "arb", then all with "watermelon". Going through all the elements in an array for a match is not very cool, how best to organize this? I would like to find an efficient solution. I can make any structrute out of an array if needed :)
Answer the question
In order to leave comments, you need to log in
In theory, it would be ideal to build a prefix tree. Here, here the Khabrovchanin explains: https://habrahabr.ru/post/111874/
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question