443. String Compression - Day 2/31 Leetcode March Challenge

Sdílet
Vložit
  • čas přidán 28. 02. 2023
  • Larry solves and analyzes this Leetcode problem as both an interviewer and an interviewee. This is a live recording of a real engineer solving a problem live - no cuts or edits!
    Problem: leetcode.com/problems/string-...
    Twitch: / larryny
    Discord: / discord
    Instagram: / larrysomewhere
    #leetcode #coding #programming
  • Věda a technologie

Komentáře • 9

  • @Algorithmist
    @Algorithmist  Před rokem +5

    Did you compress okay?

  • @Gnarz1234
    @Gnarz1234 Před rokem

    Thanks for the solution!

  • @seregaant68
    @seregaant68 Před 8 měsíci

    Good works, man of God.

  • @am_rxd
    @am_rxd Před 9 měsíci

    man you do it very like a player of the gnme for a long time something new people like me had hard time to understand this

  • @ThePriyeshpandey
    @ThePriyeshpandey Před 7 měsíci

    You look like Australian Batsman David Warner

    • @Algorithmist
      @Algorithmist  Před 7 měsíci

      Haha, I don't think so but if he's rich maybe!

    • @balajij4923
      @balajij4923 Před 3 měsíci

      @@Algorithmist he is rich as hell

  • @saiKiran-ps8ff
    @saiKiran-ps8ff Před rokem

    import json
    class Solution:
    def compress(self, chars: List[str]) -> List[str]:
    l = len(chars)
    res = chars[0]
    temp = chars[0]
    c = 1
    for i in chars[1:]:
    if i == temp:
    c += 1
    else:
    if c > 1:
    res += str(c)
    c = 1
    temp = i
    res += i
    if c > 1:
    res += str(c)
    mod_res = list(res)
    mod1_res = json.dumps(mod_res)
    return len(mod1_res)-1
    what is wrong with my leetcode 443 solution... I have a problem in returning