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

preview_player
Показать описание
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!

#leetcode #coding #programming
Рекомендации по теме
Комментарии
Автор

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

am_rxd
Автор

You look like Australian Batsman David Warner

ThePriyeshpandey
Автор

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

saiKiran-psff