討論串[閒聊] 每日leetcode
共 1554 篇文章
內容預覽:
https://leetcode.com/problems/minimum-number-of-changes-to-make-binary-string-beautiful. 2914. Minimum Number of Changes to Make Binary String Beautif
(還有681個字)
內容預覽:
2914. Minimum Number of Changes to Make Binary String Beautiful. ## 思路. 掃整個字串 並紀錄1,0的奇偶. 如果目前字元是1/0 然後有奇數個0/1 就reset並且result+1. 不然就更新1,0的奇偶. ## Code.
(還有297個字)
內容預覽:
def compressedString(self,word):. ans=[]. num=1. for i in range(len(word)):. if i<len(word)-1 and word[i]==word[i+1] and num<9:. num=num+1. else:. ans
(還有115個字)
內容預覽:
只有這種跟easy沒兩樣的medium才寫得出來了. 3163. String Compression III. public string CompressedString(string word). {. if (word.Length == 1). {. return $"1{word}";.
(還有483個字)
內容預覽:
好像很久沒寫了. 最近超級荒廢. 誰來罵倒我. 寫了一坨式. def compressedString(self, word: str) -> str:. ans = "". pre = "". cur_cnt = 0. for c in word:. if c == pre:. cur_cnt+=
(還有140個字)