464 Can I Win 我能赢吗

2021-04-15 02:26

阅读:447

标签:https   integer   ++   problem   logs   for   sed   desire   can   

详见:https://leetcode.com/problems/can-i-win/description/

C++:

class Solution {
public:
    bool canIWin(int maxChoosableInteger, int desiredTotal)
    {
        if (maxChoosableInteger >= desiredTotal)
        {
            return true;
        }
        if (maxChoosableInteger * (maxChoosableInteger + 1) / 2  m;
        return canWin(maxChoosableInteger, desiredTotal, 0, m);
    }
    bool canWin(int length, int total, int used, unordered_map& m) 
    {
        if (m.count(used))
        {
            return m[used];
        }
        for (int i = 0; i 

 参考:https://www.cnblogs.com/grandyang/p/6103525.html

464 Can I Win 我能赢吗

标签:https   integer   ++   problem   logs   for   sed   desire   can   

原文地址:https://www.cnblogs.com/xidian2014/p/8902469.html


评论


亲,登录后才可以留言!