C++ accepted solution


  • 0
    P
    class Solution {
    public:
        int lastRemaining(int n) {
        	if (n < 4) return (n+2) >> 1;
        	return (n / 2 & 1) == 0 ? 4 * lastRemaining(n / 4) - 2 : 4 * lastRemaining(n / 4);
        }
    };
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.