1impl Solution {2 pub fn last_remaining(n: i32) -> i32 {3 let mut n = n;4 let mut head = 1;5 let mut step = 1;6 let mut left = true;7 while n > 1 {8 if left || n % 2 == 1 {9 head += step;10 }11 n /= 2;12 step *= 2;13 left = !left;14 }15 head16 }17}
WPM •0 •0
ACC •0 •0
TIME •0