Minimum Number of Changes to Make Binary String Beautiful | 2 Ways | Leetcode 2914 |codestorywithMIK

แชร์
ฝัง
  • เผยแพร่เมื่อ 5 พ.ย. 2024

ความคิดเห็น • 64

  • @codestorywithMIK
    @codestorywithMIK  วันที่ผ่านมา +37

    Background me cooker ki awaaz == MIK is back to 🇮🇳 ❤
    Thank you all for supporting me and understanding my delays past week 🙏♥️

    • @kers-t6z
      @kers-t6z วันที่ผ่านมา +2

      = -> ❌ == ->✔

    • @varunpalsingh3822
      @varunpalsingh3822 วันที่ผ่านมา

      me abhi graph concepts and questions ki playlist kar rha hu, maja aa rha hai graph padhne me 😊

    • @gui-codes
      @gui-codes วันที่ผ่านมา

      yayyyy

    • @gui-codes
      @gui-codes วันที่ผ่านมา

      @@varunpalsingh3822 epic playlist hai bhai

  • @amanpaliwalvlogs6860
    @amanpaliwalvlogs6860 19 ชั่วโมงที่ผ่านมา +3

    Bhai.... Radhe Radhe ❤

  • @shubham6523
    @shubham6523 วันที่ผ่านมา +9

    best teacher ever

  • @Harsh-ho7pl
    @Harsh-ho7pl วันที่ผ่านมา +5

    That motivation part is back
    Thanks a lot for the support sir ❤️

  • @nirmalgurjar8181
    @nirmalgurjar8181 วันที่ผ่านมา +3

    Using binary operation xor makes its highly efficient:
    public int minChanges(String s) {
    int ans = 0, i = 0;
    while (i < s.length()) {
    ans += s.charAt(i++) ^ s.charAt(i++); // gives 1 when last digit is set and unset in any one position
    }
    return ans;
    }

  • @dchennaraidu
    @dchennaraidu 21 ชั่วโมงที่ผ่านมา +2

    Welcome back to 🇮🇳

  • @aadarshsonkar5170
    @aadarshsonkar5170 วันที่ผ่านมา +1

    Thank you so much bhai! Today I exactly copied your style and pattern to code by pausing and matched each and everyline with it!! I'm getting confident with each day because of you!

  • @tonishant
    @tonishant วันที่ผ่านมา +4

    Solve it my own. Thanks for the video. Your videos really helped me to build logic.

  • @akshayzade4057
    @akshayzade4057 16 ชั่วโมงที่ผ่านมา +1

    Good Logic 👍🏻

  • @Schrödinger3
    @Schrödinger3 19 ชั่วโมงที่ผ่านมา

    It was literally easiest problem ever,
    class Solution {
    public:
    int minChanges(string s) {

    int n = s.length();
    int count = 0;
    for(int i = 0; i

  • @akashdas-pp3ko
    @akashdas-pp3ko วันที่ผ่านมา

    Thanks MIK for the explanation. The finest explanation of all.
    Here is the code
    class Solution {
    public:
    int minChanges(string s) {
    int i = 0, j = 1;
    int change = 0;
    while (j < s.size()) {
    if (s[i] != s[j]) {
    change++;
    }
    i += 2, j += 2;
    }
    return change;
    }
    };
    keep shining as always.

  • @DevanshGupta-io7rl
    @DevanshGupta-io7rl วันที่ผ่านมา

    int minChanges(string s) {
    int n=s.length();
    int ans=0;
    for(int i=0;i

  • @jain5184
    @jain5184 วันที่ผ่านมา +1

    hello mik bhaiya thnku so much second approach mere dimag me aya tha but sure nhi tha me toh and apka potd wala video toh dekhna hi hai if bhale hi merese problem hojaay and and 1st approach se solve kiya apke intution is next level kaffi thought process improve hui hai and second se toh hua hi merese
    thnku once again potd banata raho mik bhaiya

  • @rushabhlegion2560
    @rushabhlegion2560 วันที่ผ่านมา

    It was easy. Took me 2 mins to figure out the solution and 1 min to write the solution
    class Solution {
    public:
    int minChanges(string s) {
    int ans = 0;
    for(int i=0; i

    • @arnabsarkar5245
      @arnabsarkar5245 วันที่ผ่านมา

      It is very good that you figured it out in 2 mins and coded it in 1 min. But there are many students who are struggling. They might get demotivated by seeing these types of comment. Hope you will understand. No hate 💗 Happy coding 🙏

  • @salmaniproductions1104
    @salmaniproductions1104 วันที่ผ่านมา +2

    It was easy, solved by own Thank you bhaiyya

  • @shivgupta5122
    @shivgupta5122 18 ชั่วโมงที่ผ่านมา +1

    you are amazinggg

  • @alokgautam02
    @alokgautam02 วันที่ผ่านมา +5

    Thanks MIK , your detailed explanation is awesome . Keep going 😇

  • @gauravbanerjee2898
    @gauravbanerjee2898 20 ชั่วโมงที่ผ่านมา

    Thanks a lot bhaiya ❤❤

  • @rakshitdevra7060
    @rakshitdevra7060 วันที่ผ่านมา

    Motivating Line💥

  • @faizanmohammed7687
    @faizanmohammed7687 วันที่ผ่านมา +1

    Pata nai ki self doubt yu karta hu, ye toh I was about to leave thinking aise question kabhi kara nai. However thode se push ke baad solved it easily with optimal approach. Bas darr reh raha hai DSA karte wqt

  • @urcristiano-t7z8f
    @urcristiano-t7z8f วันที่ผ่านมา

    Sir in approach 1 when our count is odd then we have to changed the character and reinitialise ch=[i] but this time our i pointing to changed character, i think ch =s[i+1]

  • @RohitKumar-dz8dh
    @RohitKumar-dz8dh 23 ชั่วโมงที่ผ่านมา

    Thanks 😊

  • @gauravmundhada1647
    @gauravmundhada1647 วันที่ผ่านมา

    I want to switch to product based can you tell me what should I do apart from DSA. Currently having 1 YOE. Please guide.

  • @dss963
    @dss963 วันที่ผ่านมา

    Rather than going to the approaches, it would be great to say why this greedy approach is a right solution and always guarantees the minimum number of changes.

    • @codestorywithMIK
      @codestorywithMIK  วันที่ผ่านมา

      Appreciate your feedback.
      Will take care of this thing ❤️

  • @dinobandhuchakraborty5202
    @dinobandhuchakraborty5202 23 ชั่วโมงที่ผ่านมา

    Yeh sb sawal bahut hard lagta h yr

  • @karvinus
    @karvinus วันที่ผ่านมา

    def minChanges(self, s: str) -> int:
    result = 0
    for right in range(1,len(s),2):
    if s[right]!=s[right-1]:
    result +=1

    return result

  • @vanshsoni8069
    @vanshsoni8069 23 ชั่วโมงที่ผ่านมา

    bhaiya agar example case 11000111 hai to isme different different partition me no of changes different ho sakte hai to partition se to fark padega hi na ?? 11 00 01 11 change =1 , 1100 0111 change =3 hai aise kon sa partition lena hai jisme no of changes minimum ho to different possible partition vala logic se confusion hota hai please reply !!!!!

  • @nirmalgurjar8181
    @nirmalgurjar8181 วันที่ผ่านมา +1

    Cooker ki siti sunai dene lag gayi means Sir ji wapis India aa gye .. :D

  • @karvinus
    @karvinus วันที่ผ่านมา

    Just check if 2nd position character is different from 1st and 4th is different from 3rd and so on. Count only if there are different

  • @Prajwalkulkarni
    @Prajwalkulkarni วันที่ผ่านมา +2

    maine 2nd approach brute force mai socha tha

  • @LetshaveFUN-fd9tf
    @LetshaveFUN-fd9tf วันที่ผ่านมา +1

    int minChanges(string s) {
    int n = s.length();
    int cnt = 0;
    int i=0;
    int j=1;
    while(i

    • @harsha4048
      @harsha4048 วันที่ผ่านมา +1

      Great but the for loops are more faster than while loops

  • @abhisheksinghdangi5027
    @abhisheksinghdangi5027 วันที่ผ่านมา +2

    Hm isko 2nd method s bnae .... yeah

  • @janaSdj
    @janaSdj วันที่ผ่านมา

    Thank you...

  • @onkardhingra9083
    @onkardhingra9083 13 ชั่วโมงที่ผ่านมา +1

    Leetcode ka itna hype bana dia hai ki question dekhte hi darr lagta hai. Lekin jab aapka explaination dekhta hoon toh lagta hain, kya hi easy question tha. Ye bhi nhi kar paaya.
    Zyada hi confusing language rehti hai leetcode ke questions ke...
    Aap kuch bata sakte ho, jisse khud solve karne mei asaani mille leetcode ke questions mei and darr ki jagah confidence aaye, ki mei bhi kar sakta hoon?
    Kya aapko bhi starting mei itna time lagta tha? [currently in 4th year]
    btw Thanks for making the explaination, so simple.

  • @janaSdj
    @janaSdj วันที่ผ่านมา

    Hi, can you please make a video about how to approach and solve problems during interview.

    • @B-Billy
      @B-Billy วันที่ผ่านมา +1

      Practice Practice Practice!! Nothing else.

  • @meetdobariya8777
    @meetdobariya8777 20 ชั่วโมงที่ผ่านมา +1

    cooker ki avaz vala very funny....

  • @ArnobBokshi
    @ArnobBokshi วันที่ผ่านมา +2

    my solution :
    class Solution {
    public:
    int minChanges(string s) {
    int count = 0; char prev;
    for(int i = 0 ; i

  • @RishabhChatterjee-fg2gz
    @RishabhChatterjee-fg2gz วันที่ผ่านมา

    bhaiya mere dimag mein pehle edge cases jese ki smallest string length 2 ka hi ho sakta hai, to usko check kiya, aur return kar diya, and then check before partitioning, ki given string contains only one or zero which one, and return , and if one and zero dono contain kar rahe hai, tab mene string ko divide by 2 karke length mein substring mein thoda, and recursion call kiya, and after partitoning if it's odd length, then minimum count of zero and one, else if it's length 2, then check and return.
    but my approach passes 307/544 cases, that's why don't solved by own, solved after seeing video. Can you pls make video how to approach every problem on evry topic, it's very helpful. please

  • @mayank.malviyaa
    @mayank.malviyaa วันที่ผ่านมา

    Bro indirectly proves that he is a hacker 17:47

  • @Akashkumar_12
    @Akashkumar_12 22 ชั่วโมงที่ผ่านมา

    bhaiya JEE advanced 3 attempts ho gaya 🥲

  • @Alecxender_Shorts
    @Alecxender_Shorts วันที่ผ่านมา

    class Solution {
    public:
    int minChanges(string s) {
    int n = s.length();
    char prev;
    int count =0;
    for(int i=0;i

  • @yagyanshsharma2651
    @yagyanshsharma2651 17 ชั่วโมงที่ผ่านมา +1

    cooker op

  • @pushpendrasingh3470
    @pushpendrasingh3470 วันที่ผ่านมา

    my solution:
    class Solution {
    public:
    int minChanges(string s) {
    int ans = 0;
    for (int i = 1; i < s.size(); i += 2) {
    int one = 0, zero = 0;
    if (s[i] == '1') {
    one++;
    } else
    zero++;
    if (s[i - 1] == '1') {
    one++;
    } else {
    zero++;
    }
    ans += min(one, zero);
    }
    return ans;
    }
    };

  • @ShashankShekharShukla-xw7rc
    @ShashankShekharShukla-xw7rc 18 ชั่วโมงที่ผ่านมา +1

    Again sorry for late submission
    THODA GREEDY SOCHA AUR HAR CHAGE KO CALCULATE KIYE
    int minChanges(string s) {
    int n=s.length();
    int i=0; int reqBeautyChange=0;
    while(i O(N)
    SPACE => Constant O(1)

  • @kondkartauqeer5503
    @kondkartauqeer5503 22 ชั่วโมงที่ผ่านมา

    this question is not easy at all... I don't understand where I am going wrong... I have been solving questions for like one and half year now and solved more than 1000+ questions and still couldn't be able to figure out how to solve this one.....

  • @Siddharthsirsate77
    @Siddharthsirsate77 วันที่ผ่านมา +1

    😂

    • @codestorywithMIK
      @codestorywithMIK  วันที่ผ่านมา +2

      Cooker background noise is an emotion 😉

  • @For_Indian937
    @For_Indian937 19 ชั่วโมงที่ผ่านมา

    thank you bhaiya, for this video❤