摘要:
class Solution { public: int maxProfit(vector<int>& prices) { int res=0; for(int i=0;i<prices.size()-1;i++) res+=max(0,prices[i+1]-prices[i]); return 阅读全文
posted @ 2023-05-09 15:54
穿过雾的阴霾
阅读(15)
评论(0)
推荐(0)
摘要:
class Solution { public: int maxProfit(vector<int>& prices) { int buy=prices[0],n=prices.size(),res=0;//记录最小值 for(int i=1;i<n;i++)//枚举第几天卖出 { res=max( 阅读全文
posted @ 2023-05-09 15:25
穿过雾的阴霾
阅读(13)
评论(0)
推荐(0)
摘要:
思路 如果一个数字出现 3 次,那么它的二进制表示的每一位也出现三次,如果把所有出现三次的数字的二进制表示的每一位都分别加起来,那么每一位的和都能被 3 整除 cnt[32] 数组存储每一位 1 出现的次数 遍历数组中所有数,将其二进制表示记录在 cnt 数组里 遍历 cnt 数组,根据 cnt[i 阅读全文
posted @ 2023-05-09 14:45
穿过雾的阴霾
阅读(23)
评论(0)
推荐(0)