python解决速算机器人问题

2025-10-14 18:19:37

1、参考示例 1:

 

    输入:s = "AB"

 

    输出:4

 

    解释:

 

    经过一次 A 运算后,x = 2, y = 0。

 

    再经过一次 B 运算,x = 2, y = 2。

 

    最终 x 与 y 之和为 4

python解决速算机器人问题

2、只需要一行代码搞定,实现代码:

class Solution:

    def calculate(self, s: str) -> int:

        return 2**len(s)

python解决速算机器人问题

3、提交通过

python解决速算机器人问题

声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
猜你喜欢