摘要: class Solution { public: int f[1010][1010];//f[i][j]表示s[i~j]之间的最长序列 int INF=0x3f3f3f3f; int longestPalindromeSubseq(string s) { int n=s.size(); s=' '+ 阅读全文
posted @ 2023-05-07 20:02 穿过雾的阴霾 阅读(11) 评论(0) 推荐(0)
摘要: class Solution { public: bool res=true; int dfs(TreeNode* root)//返回以root为根节点的子树深度 { if(root==NULL) return 0; int l=dfs(root->left),r=dfs(root->right); 阅读全文
posted @ 2023-05-07 17:01 穿过雾的阴霾 阅读(6) 评论(0) 推荐(0)
摘要: class Solution { public: int treeDepth(TreeNode* root) { if(!root) return 0; return max(treeDepth(root->left),treeDepth(root->right))+1; } }; 阅读全文
posted @ 2023-05-07 17:01 穿过雾的阴霾 阅读(19) 评论(0) 推荐(0)
摘要: class Solution { public: TreeNode* res=NULL; void mid(TreeNode* root, int k,int &cnt) { if(!root) return; mid(root->left,k,cnt); cnt++; if(cnt==k) res 阅读全文
posted @ 2023-05-07 17:00 穿过雾的阴霾 阅读(13) 评论(0) 推荐(0)