2021-5-1

一、英语

1、wonder at:对……感到惊讶、吃惊

2、complaisance:讨好,殷勤

3、complacency:自满、沾沾自喜

5、reverie:幻想、白日梦

6、I travel to the Binghai Area by light railway every day, as do many businessmen who live in downtown Tianjin.
as引导方式状语从句,其后应该接S+V,但是这里直接有个do,因为发生了省略:as many businessmen who live in downtown Tianjin travel to the Binghai Area by light railway ,则重复,因此直接使用do代替travel to the Binghai Area by light railway,为了避免头重脚轻,那么将do提前。

7、All the dishes in this menu,unless otherwise stated, will serve two to three people.
unless引导的条件状语从句,应该为unless they are stated otherwise will server two to three people,省略了they are并将otherwise提前。

二、算法题目

1、342:二进制的特点

class Solution {
public:
//首先判断是否为2的幂次:n&(n-1)?=0
//然后只有2的偶次幂上的为1才是4的幂次
//数字表示的折中:16进制比较实用
//注意位运算的优先级比较低,应该打上括号
    bool isPowerOfFour(int n) {
        return n>0 && ((n&(n-1)) == 0) && ((n&0xaaaaaaaa)==0);
    }
};

2、318:位运算解决字符问题

class Solution {
public:
//暴力方法:两层循环,每次判断两个字符串是否有相同的字符
//优化,使用位运算进行存储是否有相同字母的信息,并且位运算较快
//unordered_map不存在的时候会初始化一个默认值,所以可以直接使用[]
//但是map是有序的,直接访问会存在问题,访问之前应该用find进行下判断
    int maxProduct(vector<string>& words) {
        unordered_map<int,int> letters;
        int n = words.size();
        int res = 0;
        int tmp = 0;
        //每个word与已经保存的字符进行比较
        for(int i = 0;i<n;++i)
        {
            int len = words[i].size();
            tmp = 0;
            for(int j = 0;j<len;++j)
            {
                tmp |= 1<<(words[i][j]-'a');
            }
            //letters[tmp] = tmp;
            letters[tmp] = max(len,letters[tmp]);
            for(const auto& [l_num,l_len]:letters)
            {
                if((tmp&l_num)==0)
                res = max(res,len*l_len);
            }
            //letters[tmp] = len;
        }
        return res;
    }
};

五月也要继续努力!
在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值