filmov
tv
Sliding Window 3 - Medium - Longest Substring with K Distinct Characters - JAVA

Показать описание
Coding Interviews- Longest Substring with K Distinct Characters (LeetCode)
This interview question is commonly asked by companies like Microsoft, Facebook, Amazon.
In this video we have solved the problem using Sliding Window + HashMap approach along with visual representation of example.
Time Complexity -
The outer for loop FOR each element , and the inner WHILE loop processes each element only once.
O(N + N) ~= O(N)
Space Complexity -
As we will be storing a maximum of 'K+1' characters in the HashMap, the space complexity will be
O(K)
Link to the videos of Sliding Window playlist
Know more about me
This interview question is commonly asked by companies like Microsoft, Facebook, Amazon.
In this video we have solved the problem using Sliding Window + HashMap approach along with visual representation of example.
Time Complexity -
The outer for loop FOR each element , and the inner WHILE loop processes each element only once.
O(N + N) ~= O(N)
Space Complexity -
As we will be storing a maximum of 'K+1' characters in the HashMap, the space complexity will be
O(K)
Link to the videos of Sliding Window playlist
Know more about me