filmov
tv
1750 Minimum Length of String After Deleting Similar Ends LeetCode Java Solution - 2 Pointers

Показать описание
1750. Minimum Length of String After Deleting Similar Ends - LeetCode - Java Solution Explained Using 2 Pointers Approach
If you find this video helpful, please 'Like' & 'Subscribe'.
This is really helpful for the channel and also motivates me to do more of such good videos.
Approach: 2 pointers, Start and End. we will consume same characters prefix and suffix of the strings and keep moving both pointers. Start will move ahead and End will move in opposite direction, until they cross each other.
Link To The Problem:
Problem Description:
Given a string s consisting only of characters 'a', 'b', and 'c'. You are asked to apply the following algorithm on the string any number of times:
Pick a non-empty prefix from the string s where all the characters in the prefix are equal.
Pick a non-empty suffix from the string s where all the characters in this suffix are equal.
The prefix and the suffix should not intersect at any index.
The characters from the prefix and suffix must be the same.
Delete both the prefix and the suffix.
Return the minimum length of s after performing the above operation any number of times (possibly zero times).
#coding #softwareengineer #Leetcode #Algorithm #DataStructure #Java #programmer #tech #software #codinglife #Preparation
#interview #programminglife #programmingisfun
If you find this video helpful, please 'Like' & 'Subscribe'.
This is really helpful for the channel and also motivates me to do more of such good videos.
Approach: 2 pointers, Start and End. we will consume same characters prefix and suffix of the strings and keep moving both pointers. Start will move ahead and End will move in opposite direction, until they cross each other.
Link To The Problem:
Problem Description:
Given a string s consisting only of characters 'a', 'b', and 'c'. You are asked to apply the following algorithm on the string any number of times:
Pick a non-empty prefix from the string s where all the characters in the prefix are equal.
Pick a non-empty suffix from the string s where all the characters in this suffix are equal.
The prefix and the suffix should not intersect at any index.
The characters from the prefix and suffix must be the same.
Delete both the prefix and the suffix.
Return the minimum length of s after performing the above operation any number of times (possibly zero times).
#coding #softwareengineer #Leetcode #Algorithm #DataStructure #Java #programmer #tech #software #codinglife #Preparation
#interview #programminglife #programmingisfun