討論串[閒聊] 每日leetcode
共 1554 篇文章
內容預覽:
就greedy找下去. 有找到相同or差一個的就先配對掉. 寫醜醜. def canMakeSubsequence(self, str1: str, str2: str) -> bool:. i,j = 0,0. while i<len(str1):. if j>=len(str2):. break
(還有112個字)
內容預覽:
2825. Make String a Subsequence Using Cyclic Increments. ## 思路. 用pointer i 紀錄目前對應的str2字元. 掃str1比對對應的str2字元 有match就i+1. 如果指標到底就回傳TRUE. ## CODE. ```pyth
(還有380個字)
內容預覽:
我以為是考雙指針. 隨便寫寫贏過90%. 又水了一天. Java code:. --------------------------------------------------------. class Solution {. public String addSpaces(String s,
(還有338個字)
內容預覽:
還蠻男的. 不過有過就好. 寫的好像也不是很好. def addSpaces(self, s: str, spaces: List[int]) -> str:. ans = "". cur_i = 0. for i,c in enumerate(s):. if cur_i<len(spaces) a
(還有249個字)
內容預覽:
https://leetcode.com/problems/adding-spaces-to-a-string. 2109. Adding Spaces to a String. 在指定index插空格. Example 1:. Input: s = "LeetcodeHelpsMeLearn",
(還有730個字)