【算法打卡---7.24】

提示:以下是本篇文章正文内容,下面案例可供参考

一、 Nim游戏

class Solution {
public:
    bool canWinNim(int n) {
         if(n/4==0) return true; 
         if(n%4==0)  return false; 
        return true;

    }
};

【算法打卡---7.24】_第1张图片

二、 灯泡开关

class Solution {
public:
    int bulbSwitch(int n) {
     return sqrt(n);
    }
};

【算法打卡---7.24】_第2张图片

总结

只要学不死,就往死里学。

你可能感兴趣的:(每日一练,leetcode,算法,职场和发展)