随笔分类 -  leetcode

上一页 1 2 3 4 5 6 7 ··· 19 下一页
摘要:问题: 给定有0和1构成的二维数组, 求数组中,连续 1 构成正方形的面积最大是多少。 Example 1: Input: matrix = [["1","0","1","0","0"],["1","0","1","1","1"],["1","1","1","1","1"],["1&quo 阅读全文
posted @ 2021-03-31 15:20 habibah_chang
摘要:问题: 给定字符串s,和词典wordDict 若s可拆分成多个子串,存在于词典中,则返回true。否则返回false。 Example 1: Input: s = "leetcode", wordDict = ["leet","code"] Output: true Explanation: Ret 阅读全文
posted @ 2021-03-31 14:33 habibah_chang
摘要:问题: 给定一个数组,求任意区间[left, right]的元素和。 Example 1: Input ["NumArray", "sumRange", "sumRange", "sumRange"] [[[-2, 0, 3, -5, 2, -1]], [0, 2], [2, 5], [0, 5]] 阅读全文
posted @ 2021-03-31 14:00 habibah_chang
摘要:问题: 给定3个字符串, 由s1和s2构成s3。 若可以做到,返回true,否则返回false。 Example 1: Input: s1 = "aabcc", s2 = "dbbca", s3 = "aadbbcbcac" Output: true Example 2: Input: s1 = " 阅读全文
posted @ 2021-03-25 15:05 habibah_chang
摘要:问题: 求从0 到 小于给定n 的正整数中,有多少个素数(质数)。 素数:只能被 自己 和 1 整除。(1和0不是) Example 1: Input: n = 10 Output: 4 Explanation: There are 4 prime numbers less than 10, the 阅读全文
posted @ 2021-03-25 13:37 habibah_chang
摘要:问题: 求有多少个数的阶乘结果,末尾含有K个0的。 Example 1: Input: K = 0 Output: 5 Explanation: 0!, 1!, 2!, 3!, and 4! end with K = 0 zeroes. Example 2: Input: K = 5 Output: 阅读全文
posted @ 2021-03-24 15:55 habibah_chang
摘要:问题: 求给定n的阶乘结果中,有多少个0。 Example 1: Input: n = 3 Output: 0 Explanation: 3! = 6, no trailing zero. Example 2: Input: n = 5 Output: 1 Explanation: 5! = 120 阅读全文
posted @ 2021-03-24 15:05 habibah_chang
摘要:问题: 给定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
摘要:问题: 给定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
摘要:问题: 给定由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
摘要:问题: 给定一组数,其中每个数字都出现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
摘要:问题: 求给定数是否为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
摘要:问题: 给定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
摘要: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
摘要:问题: 求给定的两个字符串S1和S2是否 S1能经过以下变换得到S2。 若字符串长度为1,直接返回。 从任意index,进行切分,pre和post两部分, 可以选择:是否对这两部分进行交换。 然后,再将分割后的两部分,分别作为对象字符串,重复上述两个操作。 Example 1: Input: s1 阅读全文
posted @ 2021-03-22 17:50 habibah_chang
摘要:问题: 给定由 "(" 和 ")" 构成的字符串, 求其中完全匹配的子串,最长长度为多少。 Example 1: Input: s = "(()" Output: 2 Explanation: The longest valid parentheses substring is "()". Exam 阅读全文
posted @ 2021-03-22 16:04 habibah_chang
摘要:问题: 爬楼梯问题。 给定n阶台阶,一次可以爬一阶or两阶。 求一共有多少种爬楼梯的方法。 Example 1: Input: n = 2 Output: 2 Explanation: There are two ways to climb to the top. 1. 1 step + 1 ste 阅读全文
posted @ 2021-03-22 14:38 habibah_chang
摘要:问题: 给定n*m二维数组代表陆地和海洋。 1:海洋 0:陆地 对这个地图,进行高度赋值。 规定海洋高度一律为0。 相邻两个cell的高度差不能超过 1。(可以为 0 or 1) 那么要使map上获得最高高度。 求所得到地图高度。 Example 1: Input: isWater = [[0,1] 阅读全文
posted @ 2021-03-21 12:38 habibah_chang
摘要:问题: 给定一个由0~9构成的字符串s 对其有两种操作: 偶数位置+a(超过9,则从0开始循环) 例:if s = "3456" and a = 5, s becomes "3951". 字符串向后移动 b位(后面的字符循环到字符串前部) 例:if s = "3456" and b = 1, s b 阅读全文
posted @ 2021-03-21 11:50 habibah_chang
摘要:问题: 给定一棵以0为root的树, 给定 该树的节点连接关系。 每个节点上标记的字母。 求以各个节点为root的子树中,拥有和该节点标记字母相同节点的个数。 Example 1: Input: n = 7, edges = [[0,1],[0,2],[1,4],[1,5],[2,3],[2,6]] 阅读全文
posted @ 2021-03-21 11:47 habibah_chang

上一页 1 2 3 4 5 6 7 ··· 19 下一页