2048. 下一个更大的数值平衡数

用个vector就超时什么鬼

垃圾题

再次证明,水题不要用stl

class Solution {
public:
    bool check(int n)
    {
        int vis[10];
        memset(vis, 0, sizeof(vis));
        while(n)
        {
            int tmp = n % 10;
            n /= 10;
            if(tmp == 0) return false;
            vis[tmp]++;
        }
        for(int i = 1; i < 10; i++)
            if(vis[i] && vis[i] != i) return false;
        return true;

    }

    int nextBeautifulNumber(int n) {
        for(int i = n + 1; ; i++)
            if(check(i)) return i;


        
    }
};

 

posted @ 2021-11-25 22:58  WTSRUVF  阅读(25)  评论(0编辑  收藏  举报