daily plan

反转字符串 reverse(s.begin()+l,s.begin()+r+1);
从l到r的反转 r+1才行
s.erase(s.begin()+l); 删除一个字符的
leetcode 151. 反转字符串中的单词 主要是不占用额外空间
思路:先反转整个字符串 再去除前后,和中间冗余的空格,再挨个反转单词

#128 最长连续序列 哈希解决 
把数组转存到 set/unordered_set 中
auto v : m
m.erase(key)
m.find(key)
m.count(key)//
set是有序的 / unordered_set 是无序的 
因此 unordered 添加删除是 常数复杂度
set是logn复杂度
class Solution {
public: 
    ListNode* sortList(ListNode* head) {
    if(!head || !head->next) return head;
    ListNode* s=head;
    int len=1;
    while(s->next){s=s->next;len++;}
    for(int i=1;i<len;i*=2){
        s=new ListNode(0);
        ListNode* a=head,*b=head,*tmp=s;
        int step=ceil(0.5*len/i);
        cout<<i<< "i,step "<<step<<len<<endl;
        for(int k=0;k<step;k++){
            ListNode * v=s->next;
            for(int j=0;j<k*i;j++)v=v->next;
            a=v,b=v;
            cout<<a->val;
            int p=0,q=0;
            for(int y=i;y>0;y--) if(b && b->next) b=b->next; else b=NULL;
            for(int x=i*2;x>0;x--){
                if(b) cout<<a->val<<" a,b "<<b->val<<endl;
                else cout<<"no b"<<endl;
                if(!b || ( p<i && a->val <= b->val) || q==i) {tmp->next=a; a=a->next; p++; }
                else  {tmp->next=b; b=b->next;  q++; }
                tmp=tmp->next; 
                if(p==i && !b) break;
            }
            ListNode *vv=s->next;
            while(vv){cout<<vv->val<<endl; vv=vv->next;}
        }
    }
    return s->next;
    }
};

排序链表一定要会做!字节之前都考过 一次了 感觉秋招是逃不过滴!

class Solution {
public://字典 先修课程,和他们的数量
    bool canFinish(int nums, vector<vector<int>>& pre) {
        vector <int> in(nums,0);//记录 入度
        vector<vector<int>> graph(nums);
        for(int i=0;i<pre.size();i++){
            int a=pre[i][0],b=pre[i][1];
            ++in[a];
            graph[b].push_back(a);
        }
        int vis=0;
        queue<int> q;
        for(int i=0;i<nums;i++) if(in[i]==0) q.push(i);
        while(!q.empty()){
            int cur=q.front(); q.pop(); vis++;
            for (auto &next:graph[cur]){
                if(--in[next]==0) q.push(next);
            }
        }
        return vis==nums;
    }
};

树形dp
子结构是一棵子树
通过dfs遍历树 并且后序(遍历过叶子结点后再根据叶子结点)改变dp数组大小

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
帮我看看这段话有没有语法错误:The first effect of guaranteeing people have basic financial products and services is increasing the overall quality of people’s lives. Ensuring reliable access to financial products and services can contribute to helping families and companies plan the future from two aspects, long-term goals and unexpected emergencies (The World Bank, 2022). Long-term goals mean long-term investments such as investments in health: saving money against illness, saving for a child’s education, saving for a house or car, etc. Unexpected emergencies mean managing risk, that is, people can apply for a loan from the bank when they are in the face of a sudden bankruptcy or business shock. Furthermore, when people meet weather financial shocks, the government and banks will give some financial assistance. With these financial services, people have a basic guarantee of life and a clear plan for the future in the meanwhile. Guarantee of financial services leads them to save a sum of money in a safe bank account for buying a house, providing funds for children’s education, and buying medical insurance for both themselves and their families to prevent the sudden arrival of diseases. In daily life, online payment improves life efficiency such as reducing queuing time. Additionally, in occupational life, financial guarantees can encourage and empower young people can be bolder to pursue their entrepreneurial dreams by providing them with start-up funds from banks. All in all, the guarantee of financial products leads to individuals plan for their financial futures and improve their overall quality of life.
05-05

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值