942. DI String Match
1.問題
給予一個只有'I'或'D'的字串, 回傳任意list:
如果S[i]為'I', 則A[i] < A[i + 1]
如果S[i]為'D', 則A[i] > A[i + 1]
2.想法
當I時, 插入前面的數字; 當D時, 插入後面的數字
3.程式碼
Last updated
給予一個只有'I'或'D'的字串, 回傳任意list:
如果S[i]為'I', 則A[i] < A[i + 1]
如果S[i]為'D', 則A[i] > A[i + 1]
當I時, 插入前面的數字; 當D時, 插入後面的數字
Last updated