Thanks. You will be thrilled to know that, along with our regular content, you can now get something extra. As part of our KZbin channel memberships, we will be offering a variety of exclusive perks, including virtual video collaborations, member-only polls, and premium content exclusively for our members. Whether it's dedicated interview questions on Java threads and concurrency, a deep dive into system design components, or detailed Spring Boot project plans, all this exclusive content is just for you. Ready to become a valued member? Click this link - kzbin.info/door/iWsQBA97JYGntWs99ZrQmwjoin
@AbhishekKumar-dm6ss Жыл бұрын
Great Explanation👏👍🏻👍🏻👌
@venkateshhs377611 ай бұрын
Thank you.
@codewithease-byvarsha10 ай бұрын
You're welcome! If you could spare 3 mins to help this channel grow further, kindly nominate me here for National Creator Awards. For more details : tinyurl.com/bdhuj237
@anulipidas8300 Жыл бұрын
👍👍👍👍good👍👍👍
@_akashchaudhary Жыл бұрын
undercooked food served
@nikhilkumarjamwal5322 Жыл бұрын
for non-repeat why did we not use while loop? can you explain it?
@codewithease-byvarsha Жыл бұрын
Great question, there's a catch. Firstly, in the github link, if you notice "nonrepeat" is a variable which is calculated in the previous line, if you use a while loop even if left pointer is incremented the value of nonrepeat stays the same and can cause IndexOutOfBounds Exception. Coming to the question of while vs if, it is essentially the same thing because you effectively need to shrink the window by 1 character as it is at most k times, even if you use a while loop, it will run only once and next time it will become equal to k which is fine as we need at most k. Try few testcases with a dry-run and use a while loop you will get it.
@_DEBANJANDHAR9 ай бұрын
public class LongRepeatCharReplace { static int longestsubstring(String s, int k){ int alphabet[] = new int[26]; int maxRepeatingChar = 0; int maxLength = 0; int left = 0; for(int right = 0; right < s.length(); right++){ char ch = s.charAt(right); alphabet[ch - 'A']++; maxRepeatingChar = Math.max(maxRepeatingChar, alphabet[ch - 'A']); //Window size -> right-left+1 int needReplacement = right-left+1 - maxRepeatingChar; while(needReplacement > k){ alphabet[s.charAt(left) - 'A']--; left++; needReplacement = right-left+1 - maxRepeatingChar; } maxLength = Math.max(maxLength, right-left+1); } return maxLength; } public static void main(String[] args) { String s = "AABABBA"; int k = 1; int ans = longestsubstring(s, k); System.out.println(ans); } }
@Brute_Coder Жыл бұрын
IDK Why ......you explained the approach well but then you just took a naive testcase and explained that .... not getting into the internal working of the algo ....
@codewithease-byvarsha Жыл бұрын
You are right, I agree, I could have used a better example for the dry-run. Thanks for your feedback!
@parassaharan41432 ай бұрын
@@codewithease-byvarsha nahh it's good
@rishavkalra384311 ай бұрын
thanks mam
@codewithease-byvarsha10 ай бұрын
Most welcome 😊 If you could spare 3 mins to help this channel grow further, kindly nominate me here for National Creator Awards. For more details : tinyurl.com/bdhuj237
@surajsidar32805 ай бұрын
Start of the video is not good. I know you are trying to give a preview of the video. (Entertainment and Infotainment do like this) When I played the video I thought how can someone start without even reading the question.