We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Hi, This is C# solutions with strong linq use.
1. Get all distinct pairs of chars, put in c# Dictionary with empty value "".
For each char in input string
a) select pairs that contains this char
b) if current string value is empty or last char is different then current add new char at the end.
c) if last char in string value is the same - pair is invalid -remove dictionary value.
Return length of longest string value from dict or 0.
Could someone write what is the complexity of this solution?
Two Characters
You are viewing a single comment's thread. Return to all comments →
Hi, This is C# solutions with strong linq use. 1. Get all distinct pairs of chars, put in c# Dictionary with empty value "".
For each char in input string a) select pairs that contains this char b) if current string value is empty or last char is different then current add new char at the end. c) if last char in string value is the same - pair is invalid -remove dictionary value.
Return length of longest string value from dict or 0.
Could someone write what is the complexity of this solution?