S
S
sergeevpetro2016-08-05 15:57:44
C++ / C#
sergeevpetro, 2016-08-05 15:57:44

How to do an array search?

Hello!
I’m stupid, but I can’t figure out whether it is possible to solve the following problem without explicit cycles:
There is an array of roots for male names / patronymics: Gennad, Il, Vladislav, Grigor, etc.
How to check if the word "Gennady" has a match from this array?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
A
akass, 2016-08-05
@sergeevpetro

string test = "Геннадий";
bool result = Roots.Any(x=> test.Contains(x));

G
GavriKos, 2016-08-05
@GavriKos

No cycles? Even without the implicit ones (Contains contains a loop)? IMHO no.

R
Roman Mirilaczvili, 2016-08-05
@2ord

Without cycles - it means library means?
stackoverflow.com/a/10366607
Algorithms: Aho-Korasik, KMP.

M
MrDywar Pichugin, 2016-08-05
@Dywar

I think the cycle means the passage through all the elements.
And if you split the data so that you don’t have to do this (tree), then the answer is yes.
Like - the first letter 'G' - yes / no, this already removes 32 letters and everything below them, i.e. no longer a cycle.
And Many .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question