Swap two Strings without using temp/third variable - Java Interview Questions -9

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

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

  • @nibeditajinu
    @nibeditajinu 3 ปีที่แล้ว +4

    Seen some of your videos.. There are other TH-camr who explained these concepts But Must say this - The way you explain ,is extraordinary, it just get typed into memory ( human Lol) and never get erased

  • @ckumar89
    @ckumar89 6 ปีที่แล้ว +29

    one more:
    s1=s1+s2;
    s2=s1.replace(s2, "");
    s1=s1.replace(s2, "");

  • @soumyacc4209
    @soumyacc4209 ปีที่แล้ว +1

    Hi Naveen,
    Your videos are amazing and worth watching. It gives more confidence to viewers and helps a lot to attend any interviews and apply this concept in real projects. Your framework videos are just WAW! and your way of breaking and explaining the concepts is beautiful. My best wishes to you.

  • @uyghurfilms3450
    @uyghurfilms3450 5 ปีที่แล้ว +5

    How many “thank you “ is enough for your efforts? Lol thank you from my deep heart

  • @sahilkhenat1817
    @sahilkhenat1817 2 ปีที่แล้ว

    I wrote little different logic by using strip function in Python and it worked.
    #Swap StringsPython
    a = "hello"
    b = "world"
    print(a,b)
    a = a+b
    difflength= len(a) - len(b)
    b = a[0:(difflength)]
    a = a.strip(b)
    print(a,b)

  • @pradeepb6914
    @pradeepb6914 6 ปีที่แล้ว +2

    Thank you Naveen for your efforts.
    Solution of above using replace function
    String s1 = "Hello";
    String s2 = "World";
    // Using replace
    s1 = s1.concat(s2);
    s2 = s1.replace(s2, "");
    s1 = s1.replace(s2, "");
    System.out.println(s1 +" | "+s2);

    • @amitmoolchandani8945
      @amitmoolchandani8945 6 ปีที่แล้ว

      this will not work when s1 = "HelloWorld" and s2 = "World"

    • @sruthitenneti3821
      @sruthitenneti3821 6 ปีที่แล้ว +1

      we can use replaceFirst instead of replace

    • @Itsme1n1ly
      @Itsme1n1ly 6 หลายเดือนก่อน

      Nice edge case ❤

  • @hi-ks4rl
    @hi-ks4rl 6 ปีที่แล้ว +2

    More interview java videos will be useful.your approach is very easy to understand.

  • @SmartProgramming
    @SmartProgramming 6 ปีที่แล้ว +1

    helpful tutorial, thank you, keep it up 👍👍👍👍

  • @artimandale8286
    @artimandale8286 6 หลายเดือนก่อน +1

    Amazing explanation, thank you Naveen

  • @durdonatursunova292
    @durdonatursunova292 6 ปีที่แล้ว +1

    Hi Neveen,
    Thank you for your time. All videos are very useful.

  • @priyankagoel4448
    @priyankagoel4448 4 ปีที่แล้ว +1

    Thank you Naveen ,it's really helpful

  • @gauravakash8237
    @gauravakash8237 3 ปีที่แล้ว +1

    one more
    String a= "akash"
    String b= "Gaurav"
    System.out.println("The new value of a will be " + b.Substring(0) );
    System.out.println("The new value of b will be " + a.Substring(0) );

  • @clearaj710
    @clearaj710 5 ปีที่แล้ว

    Can you please explain a program which is checking the drop down string values are in alphabetical order?

  • @elkememet701
    @elkememet701 4 ปีที่แล้ว

    Thanks

  • @kalaimohan5421
    @kalaimohan5421 2 ปีที่แล้ว

    Thank u

  • @sunilreddymallela
    @sunilreddymallela 6 ปีที่แล้ว

    Why css selector is faster than xpath , if it is fast why most of the automation engieers are preferred to write mostly custom xpath in place of custom css selectors

    • @sajindraprasad
      @sajindraprasad 6 ปีที่แล้ว +3

      Sunil Kumar Reddy Mallela css is faster but using css selector we cannot navigate forward or backward inside Dom.So xpath is used in this case

  • @narendrareddy4477
    @narendrareddy4477 11 วันที่ผ่านมา

    This is one of the most confusing explanation from Naveen at a = a.substring(b.length());. Didn't explain clearly. So disliking the video. Sorry

  • @samshoaib6871
    @samshoaib6871 4 ปีที่แล้ว

    One More Way ;-)
    String a = "Hello";
    String b = "World";


    System.out.println("A: "+a);
    System.out.println("B: "+b);

    a = a+b;
    b=a.substring(0, 5);
    a=a.substring(5, 10);

    System.out.println("A after swapped from Hello to: "+a);
    System.out.println("B after swapped from World to: "+b);

    • @ashwinib5017
      @ashwinib5017 3 ปีที่แล้ว

      This solution will work only if both strings is length 5 , Naveen s solution works for any string length

    • @Itsme1n1ly
      @Itsme1n1ly 6 หลายเดือนก่อน

      It's not Scalable