app开发者平台在数字化时代的重要性与发展趋势解析
781
2022-08-25
LeetCode-942. DI String Match
Given a string S that only contains "I" (increase) or "D" (decrease), let N = S.length.
Return any permutation A of [0, 1, ..., N] such that for all i = 0, ..., N-1:
IfS[i] == "I", thenA[i] < A[i+1]IfS[i] == "D", thenA[i] > A[i+1]
Example 1:
Input: "IDID"Output: [0,4,1,3,2]
Example 2:
Input: "III"Output: [0,1,2,3]
Example 3:
Input: "DDI"Output: [3,2,0,1]
Note:
1 <= S.length <= 10000S only contains characters"I" or"D".
题解:
class Solution {public: vector
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~