filmov
tv
String - 9: Find longest sub-string length with K distinct characters | Java Implementation
Показать описание
Solution:
- We take a Map, which'll give me info about unique characters present, Map key will be character & value will be the occurrence of that character
- We'll take a max_length variable, where we'll store the solution
- we'll take two variable start & end, which'll point to 1st character in string initially
- Now we iterate the string & keep on putting character in map. If size of value is greater than K, then we decrease the character from start index. If occurrence becomes 0, we remove from map.
- max_length will be updated by end - start + 1
- At last we return, max_length as answer
Time Complexity: O(n)
Space Complexity: O(n)
Do Watch video for more info
CHECK OUT CODING SIMPLIFIED
★☆★ VIEW THE BLOG POST: ★☆★
I started my YouTube channel, Coding Simplified, during Dec of 2015.
Since then, I've published over 400+ videos.
★☆★ SUBSCRIBE TO ME ON YOUTUBE: ★☆★
★☆★ Send us mail at: ★☆★
- We take a Map, which'll give me info about unique characters present, Map key will be character & value will be the occurrence of that character
- We'll take a max_length variable, where we'll store the solution
- we'll take two variable start & end, which'll point to 1st character in string initially
- Now we iterate the string & keep on putting character in map. If size of value is greater than K, then we decrease the character from start index. If occurrence becomes 0, we remove from map.
- max_length will be updated by end - start + 1
- At last we return, max_length as answer
Time Complexity: O(n)
Space Complexity: O(n)
Do Watch video for more info
CHECK OUT CODING SIMPLIFIED
★☆★ VIEW THE BLOG POST: ★☆★
I started my YouTube channel, Coding Simplified, during Dec of 2015.
Since then, I've published over 400+ videos.
★☆★ SUBSCRIBE TO ME ON YOUTUBE: ★☆★
★☆★ Send us mail at: ★☆★
String - 9: Find longest sub-string length with K distinct characters | Java Implementation
10. C# program to find longest word in a string
How to find the longest word in a String with JavaScript
String 10: Longest Distinct characters in a string | Must Do Coding Questions | GeeksForGeeks
Third Largest String [Viewer's Questions]
Javascript Challenges - How To Find the Longest Word in a String
Let's Solve 'Find the Longest Word in a String' - freeCodeCamp JavaScript Challenge
Find The Longest String In A List | Python Example
[Arabic] Problems Solving With PHP - Find Longest Word in a String
How to find Longest and Smallest word in a String | Coding Skills
DP 45. Longest String Chain | Longest Increasing Subsequence | LIS
FINDING LARGEST WORD FROM GIVEN STRING PROGRAM IN PYTHON || MAXIMUM LENGTH WORD PROGRAM IN PYTHON
Python program to accept a string from user Find and Print Longest Word and Length by Mahesh Huddar
What is the maximum length of a String in Java? - Cracking the Java Coding Interview
JavaScript Function To Find The Longest String From A Given Array Of Strings !
Code Challenge - Longest String JavaScript
Bonfire: Find the Longest Word in a String JavaScript FreeCodeCamp.com
Python Program to display the words of string from longest to shortest by Mahesh Huddar
Longest Palindrome in a String || Program 20 || Competitive Coding || Learning Monkey ||
find longest string in arrray of strings javascript | Javascript interview questions #javascript
Python Program to Find Largest Word in a String | Python Course for Beginners
Find the longest Palindrome in a string | Love Babbar DSA Sheet | Amazon🔥
7-String, 8-String, & 9-String Guitars 101 - Extended Range Guitar Lesson
STRING PROGRAMS | LONGEST WORD | LENGTH OF EACH WORD | ICSE-10 | Anjali Ma'am
Комментарии