討論串[閒聊] 每日leetcode
共 1554 篇文章

推噓1(1推 0噓 1→)留言2則,0人參與, 1年前最新作者JerryChungYC (JerryChung)時間1年前 (2024/11/05 19:33), 編輯資訊
0
0
1
內容預覽:
https://leetcode.com/problems/minimum-number-of-changes-to-make-binary-string-beautiful. 2914. Minimum Number of Changes to Make Binary String Beautif
(還有681個字)

推噓1(1推 0噓 0→)留言1則,0人參與, 1年前最新作者dont (dont)時間1年前 (2024/11/05 18:23), 編輯資訊
0
0
0
內容預覽:
2914. Minimum Number of Changes to Make Binary String Beautiful. ## 思路. 掃整個字串 並紀錄1,0的奇偶. 如果目前字元是1/0 然後有奇數個0/1 就reset並且result+1. 不然就更新1,0的奇偶. ## Code.
(還有297個字)

推噓0(0推 0噓 0→)留言0則,0人參與, 最新作者Meaverzt (Meaverzt)時間1年前 (2024/11/05 02:26), 編輯資訊
0
0
0
內容預覽:
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個字)

推噓0(0推 0噓 0→)留言0則,0人參與, 最新作者devilkool (可可粉)時間1年前 (2024/11/05 01:42), 1年前編輯資訊
0
0
0
內容預覽:
只有這種跟easy沒兩樣的medium才寫得出來了. 3163. String Compression III. public string CompressedString(string word). {. if (word.Length == 1). {. return $"1{word}";.
(還有483個字)

推噓3(3推 0噓 1→)留言4則,0人參與, 1年前最新作者DJYOMIYAHINA (通通打死)時間1年前 (2024/11/05 01:27), 編輯資訊
0
0
0
內容預覽:
好像很久沒寫了. 最近超級荒廢. 誰來罵倒我. 寫了一坨式. def compressedString(self, word: str) -> str:. ans = "". pre = "". cur_cnt = 0. for c in word:. if c == pre:. cur_cnt+=
(還有140個字)