Find the Difference - Leetcode 389 - Python

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

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

  • @gaychin8654
    @gaychin8654 11 หลายเดือนก่อน +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.

  • @infinitygod5379
    @infinitygod5379 11 หลายเดือนก่อน +4

    Liked the xor approach

  • @MP-ny3ep
    @MP-ny3ep 11 หลายเดือนก่อน +3

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

  • @Banaaani
    @Banaaani 11 หลายเดือนก่อน +2

    The last solution is just mind blowing!

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

      ikr! I never knew we could do this with bits

  • @michomapeter941
    @michomapeter941 11 หลายเดือนก่อน +1

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

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

    thank you so much for solving the daily challenges !!

  • @houssainebendhieb203
    @houssainebendhieb203 11 หลายเดือนก่อน +1

    Thank you for your efforts it's very helpful

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

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

  • @jeewan3108
    @jeewan3108 11 หลายเดือนก่อน +1

    XOR approach ❤

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

    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 11 หลายเดือนก่อน +1

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

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

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

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

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

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

      same, good one

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

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

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

    ❤❤

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

    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

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

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