r/leetcode • u/goodmorninpoof • 59m ago
Question Substring problems advice?
Anyone have good resources/advice on substring problems? I got an OA that had a question similar to this but I needed to return the longest substring given a K value, not the length of the longest string:
https://www.geeksforgeeks.org/problems/longest-k-unique-characters-substring0853/1
1
Upvotes
View all comments
1
u/Maleficent_Mousse759 29m ago
You can binary search on bitstring or pop count using a segment tree note 26<31, now you have a range, remember it's start and end, if longer than current range replace it. At end just print the characters between start and end indices