Skip to main content

All Questions

1 vote
1 answer
1k views

Performance: Use plain for loops to look for (existence of) string in string array?

I timed a few ways to look for a string in a string array (with 82 elements in the example) in a case sensitive manner plus ignoring case. I am kind of suprised, that the plain for loops are faster ...
embert's user avatar
  • 445
3 votes
1 answer
300 views

String.IndexOfAny(string, string[]) (lowest position for group of needles in haystack)

This is a follow-up to this question with bug fixes, question and code improvements from @dfhwze, @PieterWitvoet, @HenrikHansen, @t3chb0t. I am still hoping for an improved approach or algorithm ...
NetMage's user avatar
  • 422
2 votes
2 answers
1k views

Best C# implementation of IndexOfAny(string, params string[])

Follow-Up question .Net provides String.IndexOfAny(string, char[]) but not String.IndexOfAny(string, string[]). The existing ...
NetMage's user avatar
  • 422
6 votes
2 answers
6k views

Find a best fuzzy match for a string

I am trying to find a best match for a name within a list of names. I came up with the below code, which works, but I feel that the creation of the intermediate ...
barciewicz's user avatar
3 votes
0 answers
249 views

Fastest way to build string feature vectors Python

I have a list of strings to search along with a list of words and want to produce boolean feature vectors indicating presence of each word within the strings. What is the fastest way to build these ...
Danny Friar's user avatar
10 votes
2 answers
513 views

Naive implementation of KMP algorithm

After reading this answer to the question "High execution time to count overlapping substrings", I decided to implement the suggested Knuth-Morris-Pratt (KMP) algorithm. I used the pseudo-code listed ...
Graipher's user avatar
  • 41.3k
3 votes
1 answer
2k views

Detect if string contains more than 1 period

This function returns true if the string contains zero or one periods, and returns false if the string contains more than one ...
esote's user avatar
  • 3,800
6 votes
2 answers
214 views

Name filtering in Java

I have a search box for searching for people in a list of names. Here is the code that runs every time the query changes. I could not find anything open-sourced for this, so I wanted to make sure ...
Eric Cochran's user avatar
12 votes
5 answers
9k views

Fastest way of removing a substring from a string

Taking a break from my C++ series, I recently reviewed the code in this question. I ended up writing my own separate derivation of the function so that I could remove all of the substrings from a ...
syb0rg's user avatar
  • 21.9k
5 votes
4 answers
4k views

Faster method to find data using search word?

I need to search through a string array to find every occurrence of "Parameters Table", and between each "Parameters Table" and the next, get another string from a specified index (that remains ...
user2340818's user avatar
6 votes
3 answers
2k views

Search string in a list

...
Patrick's user avatar
  • 369
29 votes
5 answers
12k views

Custom indexOf() without String methods

I created my own indexOf function. I was wondering if anyone could help me come up with a way to make it more efficient. I am practicing for interviews so the catch ...
Liondancer's user avatar
  • 1,509
6 votes
3 answers
189 views

Can this FindString function be optimized further, in terms of speed?

...
Hex4869's user avatar
  • 185