zoukankan      html  css  js  c++  java
  • 848. Shifting Letters

    问题描述:

    问题规约为:对每一个数组S,移动(shifts[0] + shitfs[1]+...+shitfs[i] )mod 26位

    def shiftingLetters(self, S: str, shifts: List[int]) -> str:
            #a 97  ord: char->int   chr: int->char
            sm = sum(shifts)
                
            ans = ''
            for i in range(len(S)):
                ans += chr( (ord(S[i]) - 97 + sm) % 26  + 97)
                sm -= shifts[i]
            return ans
    

    1.把复杂问题说简单的能力
    2.构建数学模型的能力

  • 相关阅读:
    20200816
    20200815
    20200813
    20200811
    20200810
    20200806
    20200804
    20200803
    20200802
    20200801
  • 原文地址:https://www.cnblogs.com/whyaza/p/11201553.html
Copyright © 2011-2022 走看看