C# – Remove a set of characters from a string

The fastest and simplest way to remove a set of characters from a string is to use StringBuilder + List<char>, like this: I compared this with three other approaches. I did 100,000 iterations with a string with 2500 characters and a list of 15 characters to remove. This StringBuilder approach is almost 2x faster than … Read more

Algorithm Explained: Determine if two strings have a substring in common

Problem statement: Given two strings, determine if they have a substring in common. Example: Do “hello world” and “world” have a substring in common? Yes, they both have the substring “world”. Approach What are all the substrings of string? The string “word” is four characters long. It contains 10 substrings between length 1 and 4. … Read more