Find the Difference - Leetcode 389 - Python

แชร์
ฝัง
  • เผยแพร่เมื่อ 1 ก.พ. 2025

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

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

    Wow, exactly what I needed! Also, for those who don't know, XOR operation is both associative and commutative, therefore, the sequence of characters will not affect the output.

  • @MP-ny3ep
    @MP-ny3ep ปีที่แล้ว +3

    Thank you for the daily problems ! Love the multiple approaches.

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

    Liked the xor approach

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

    Bro youre the best ,We really appreciate your efforts ,Thankyou

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

    The last solution is just mind blowing!

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

      ikr! I never knew we could do this with bits

  • @ymncore
    @ymncore ปีที่แล้ว

    thank you so much for solving the daily challenges !!

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

    Thank you for your efforts it's very helpful

    • @omaryahia
      @omaryahia 7 หลายเดือนก่อน

      how is problem solving going for you? still solving? :)

  • @AF-it4ib
    @AF-it4ib 2 หลายเดือนก่อน

    Ya are a legend!!! , thanks!!!

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

    XOR approach ❤

  • @phpostrich
    @phpostrich ปีที่แล้ว

    return chr(sum([ord(ch) for ch in t]) - sum([ord(ch) for ch in s])) # one liner

    • @phpostrich
      @phpostrich ปีที่แล้ว

      return chr(reduce(lambda x, y: x ^ y, [ord(ch) for ch in (t+s)])) # one liner using reduce and XOR 🤔

    • @downhillskating101
      @downhillskating101 ปีที่แล้ว

      same, good one

  • @anantom251
    @anantom251 ปีที่แล้ว

    Did it myself today!!
    using the hashing.
    char findTheDifference(string s, string t) {
    vector mp(27,0);
    char ans = '0';
    // we first initialise the vector array with the freq of the characters of string s;
    for(auto i=0;i

  • @SASA_maxillo
    @SASA_maxillo ปีที่แล้ว

    my solution:
    if s == "":
    return t
    for i in s:
    t = t.replace(i, "", 1)

    return t
    i think it is easier and more readable 🙃🙃

    • @yourAI-Buddy
      @yourAI-Buddy ปีที่แล้ว +1

      The real deal is learning various ways than just for loops and stuff. the XOR method and ascii value calcs are pretty cool

  • @jessanraj9086
    @jessanraj9086 ปีที่แล้ว

    ❤❤

  • @rushabhlegion2560
    @rushabhlegion2560 ปีที่แล้ว

    I wrote like this
    class Solution {
    public:
    char findTheDifference(string s, string t) {
    vectorvecS(26,0);
    vectorvecT(26,0);
    for(int i=0;i

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

    what a crappy example they gave

  • @nikospappas8718
    @nikospappas8718 ปีที่แล้ว

    Another one liner
    return set(t).difference(set(s)).pop()