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.
- Two Characters
- Discussions
Two Characters
Two Characters
Sort by
recency
|
26 Discussions
|
Please Login in order to post a comment
Java 33/33 test cases, O(n^2)
C#
Python
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?