剑指OFFER----面试题62. 圆圈中最后剩下的数字

链接:https://leetcode-cn.com/problems/yuan-quan-zhong-zui-hou-sheng-xia-de-shu-zi-lcof/

代码

class Solution {
public:
    int lastRemaining(int n, int m) {
        if (n == 1) return 0;
        return (lastRemaining(n - 1, m) + m ) % n;
    }
};
posted @ 2020-03-14 14:12  景云ⁿ  阅读(123)  评论(0编辑  收藏  举报