LeetCode --- 942. DI String Match 解题报告
Posted 杨鑫newlfe
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了LeetCode --- 942. DI String Match 解题报告相关的知识,希望对你有一定的参考价值。
A permutation perm
of n + 1
integers of all the integers in the range [0, n]
can be represented as a string s
of length n
where:
s[i] == \'I\'
ifperm[i] < perm[i + 1]
, ands[i] == \'D\'
ifperm[i] > perm[i + 1]
.
Given a string s
, reconstruct the permutation perm
and return it. If there are multiple valid permutations perm, return any of them.
Example 1:
Input: s = "IDID" Output: [0,4,1,3,2]
Example 2:
Input: s = "III" Output: [0,1,2,3]
Example 3:
Input: s = "DDI" Output: [3,2,0,1]
<
以上是关于LeetCode --- 942. DI String Match 解题报告的主要内容,如果未能解决你的问题,请参考以下文章
LeetCode --- 942. DI String Match 解题报告
LeetCode 942 DI String Match 解题报告
LeetCode 942 增减字符串匹配[贪心 双指针] HERODING的LeetCode之路
LeetCode 942. 增减字符串匹配 / 1728. 猫和老鼠 II(博弈,不会) / 449. 序列化和反序列化二叉搜索树
[LeetCode] 903. Valid Permutations for DI Sequence DI序列的有效排列