摘要: 问题: 给定1~n个节点,构成(前序,中序,后序,其中任意一种)遍历的序列, 求可构成的二叉树的种类个数。 Example 1: Input: n = 3 Output: 5 Example 2: Input: n = 1 Output: 1 Constraints: 1 <= n <= 19 ex 阅读全文
posted @ 2021-03-23 16:01 habibah_chang 阅读(13) 评论(0) 推荐(0) 编辑
摘要: 问题: 给定1~n个节点,(根据1~n构成<前序,中序,后序,其中一种>遍历序列,求可构成的二叉树种类) 令这些节点构成二叉树,求所能构成的所有(不重复)二叉树。 Example 1: Input: n = 3 Output: [[1,null,2,null,3],[1,null,3,2],[2,1 阅读全文
posted @ 2021-03-23 14:51 habibah_chang 阅读(37) 评论(0) 推荐(0) 编辑
摘要: 问题: 给定由0~9构成的编码字符串。 编码前, 'A' -> "1" 'B' -> "2" ... 'Z' -> "26" 按照以上方法进行编码。 求编码前的字符串组合的可能数。 Example 1: Input: s = "12" Output: 2 Explanation: "12" coul 阅读全文
posted @ 2021-03-23 14:02 habibah_chang 阅读(16) 评论(0) 推荐(0) 编辑
摘要: 问题: 给定一组数,其中每个数字都出现2次, 只有一个数字出现了一次。求这个数字。 Example 1: Input: nums = [2,2,1] Output: 1 Example 2: Input: nums = [4,1,2,1,2] Output: 4 Example 3: Input: 阅读全文
posted @ 2021-03-23 13:14 habibah_chang 阅读(25) 评论(0) 推荐(0) 编辑
摘要: 问题: 求给定数是否为2的幂。 Example 1: Input: n = 1 Output: true Explanation: 20 = 1 Example 2: Input: n = 16 Output: true Explanation: 24 = 16 Example 3: Input: 阅读全文
posted @ 2021-03-23 12:28 habibah_chang 阅读(22) 评论(0) 推荐(0) 编辑
摘要: 问题: 给定32位无符号整型数 uint32_t n 求该数中1出现的次数。 Example 1: Input: n = 00000000000000000000000000001011 Output: 3 Explanation: The input binary string 000000000 阅读全文
posted @ 2021-03-23 12:07 habibah_chang 阅读(11) 评论(0) 推荐(0) 编辑
摘要: 1.算法运算: 1.1. 获得最低非0位: 1 //获取x的最低1位。 2 //e.g. 6 = 0110 3 //获得 2 = 10 4 // x=0110, -x=(~x+1)=(1001+1)=1010 5 // x&(-x) = 0110 & 1010 = 0010 6 int lowbit 阅读全文
posted @ 2021-03-23 11:32 habibah_chang 阅读(231) 评论(0) 推荐(0) 编辑