xinyu04

导航

2022年7月27日 #

LeetCode 101 Symmetric Tree DFS

摘要: Given the root of a binary tree, check whether it is a mirror of itself (i.e., symmetric around its center). Solution 判断树是否为对称的。我们可以直接对左右子树进行 $DFS$ 递归 阅读全文

posted @ 2022-07-27 20:10 Blackzxy 阅读(17) 评论(0) 推荐(0) 编辑

LeetCode 22 Generate Parentheses DFS

摘要: Given $n$ pairs of parentheses, write a function to generate all combinations of well-formed parentheses. Input: n = 3 Output: ["((()))","(()())","(() 阅读全文

posted @ 2022-07-27 17:03 Blackzxy 阅读(12) 评论(0) 推荐(0) 编辑

Codeforces Round #799 (Div. 4) B E F G题解

摘要: 1. B problem B 每次删除两个元素,问最后可以保留的最大的序列长度:满足序列中每个元素都不相同。 思路: 用 $map$ 来统计一下数字出现的次数。我们接着记录奇数次数以及偶数次数的个数,次数为奇数的显然可以全部保留,对于偶数的 $-1$ 点击查看代码 #include<iostream 阅读全文

posted @ 2022-07-27 04:17 Blackzxy 阅读(29) 评论(0) 推荐(0) 编辑