MCPcopy Create free account
hub / github.com/StudyRust/leetcode_rust / calculate

Function calculate

lcp17-nGK0Fy.rs:27–38  ·  view source on GitHub ↗
(s: String)

Source from the content-addressed store, hash-verified

25}
26
27pub fn calculate(s: String) -> i32 {
28 let mut x = 1;
29 let mut y = 0;
30 for c in s.chars() {
31 if c == 'A' {
32 x = 2 * x + y;
33 } else {
34 y = 2 * y + x
35 }
36 }
37 x + y
38}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected