源码之家

  • 首页
  • 文章
  • 问答
  • 下载
您的位置: 首页  >  文章  >  942. DI String Match

942. DI String Match

分类: 文章 • 2024-06-06 23:30:22

—Easy

https://leetcode.com/problems/di-string-match/

942. DI String Match

 

class Solution:
    def diStringMatch(self, S: str) :
        N = len(S)
        list_ans = []
        start = 0
        end = N
        for elt in S:
            if elt == "I":
                list_ans.append(start)
                start += 1
            if elt == "D":
                list_ans.append(end)
                end -= 1
        list_ans.append(end)
        return list_ans

# s = Solution()
# print(s.diStringMatch("IDID"))

思路:

1.题目意思第一时间没看明白,注意S与A所代表的即可

相关推荐

  • 942. DI String Match
  • 942. DI String Match
  • elasticsearch中match、match_phrase、query_string和term的区别
  • 实例演示ElasticSearch索引查询term,match,match_phase,query_string之间的区别
  • 解决Oracle报“ORA-01861: literal does not match format string”错误问题
  • leetcode942. DI String Match
  • ES query_string match的区别之一
  • Java String base64 encode algorithm to match openssl implementation
  • 变量在String.match正则表达式
  • ES query_string match的区别之一
  • leetcode之Best Time to Buy and Sell Stock III 问题
  • 【Fungus笔记】No.8:Say(说话) 的艺术
    网站免责声明 网站地图 最新文章 用户隐私 版权申明
本站所有数据收集于网络,如果侵犯到您的权益,请联系网站进行下架处理。   

Copyright © 2018-2021   Powered By 源码之家    备案号:   粤ICP备20058927号