随笔分类 -  leetcode每日一题

摘要:简单题:中序+归并 class Solution { public: vector<int> ans1,ans2,ans3; void dfs(TreeNode* root,vector<int> &ans){ if(root==nullptr) return ; dfs(root->left,an 阅读全文
posted @ 2022-05-01 23:19 秋月桐 阅读(26) 评论(0) 推荐(0)
摘要:1.先dfs,保存dfs的所有值的o(n)做法 /** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode() : va 阅读全文
posted @ 2022-04-20 19:14 秋月桐 阅读(25) 评论(0) 推荐(0)
摘要:/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode() : val(0), left(nullptr), rig 阅读全文
posted @ 2022-04-19 23:58 秋月桐 阅读(24) 评论(0) 推荐(0)
摘要:滑动窗口问题。 寻找最大长度的窗口,窗口内 'T' 或 'F'的数量为k class Solution { public: string s; int n; int gk; int getCnt(char c){ int ans=0; int j=0,cnt=0; for(int i=0;i<n;i 阅读全文
posted @ 2022-03-29 19:04 秋月桐 阅读(30) 评论(0) 推荐(0)