All Downloads are FREE. Search and download functionalities are using the official Maven repository.

g0301_0400.s0390_elimination_game.Solution Maven / Gradle / Ivy

There is a newer version: 1.37
Show newest version
package g0301_0400.s0390_elimination_game;

// #Medium #Math #Recursion #2022_07_13_Time_4_ms_(81.16%)_Space_42_MB_(71.14%)

public class Solution {
    public int lastRemaining(int n) {
        return n == 1 ? 1 : 2 * (n / 2 - lastRemaining(n / 2) + 1);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy