随笔分类 -  leetcode

上一页 1 ··· 8 9 10 11 12 13 14 15 16 ··· 19 下一页

【Leetcode_easy】697. Degree of an Array
摘要:problem 697. Degree of an Array 题意:首先是原数组的度,其次是和原数组具有相同的度的最短子数组。那么最短子数组就相当于子数组的首末数字都是统计度的数字。 solution1: solution2: 参考 1. Leetcode_easy_697. Degree of 阅读全文

posted @ 2019-06-26 17:53 鹅要长大 阅读(210) 评论(0) 推荐(0)

【Leetcode_easy】696. Count Binary Substrings
摘要:problem 696. Count Binary Substrings 题意:具有相同个数的1和0的连续子串的数目; solution1:还不是特别理解。。。 遍历元数组,如果是第一个数字,那么对应的ones或zeros自增1。然后进行分情况讨论,如果当前数字是1,然后判断如果前面的数字也是1,则 阅读全文

posted @ 2019-06-26 17:52 鹅要长大 阅读(217) 评论(0) 推荐(0)

【Leetcode_easy】693. Binary Number with Alternating Bits
摘要:problem 693. Binary Number with Alternating Bits solution1: solution2: 通过异或操作判断最低位是否在0/1之间转换进行。 参考 1. Leetcode_easy_693. Binary Number with Alternatin 阅读全文

posted @ 2019-06-26 17:50 鹅要长大 阅读(221) 评论(0) 推荐(0)

【Leetcode_easy】690. Employee Importance
摘要:problem 690. Employee Importance 题意:所有下属和自己的重要度之和,所有下属包括下属的下属即直接下属和间接下属。 solution:DFS; solution:BFS; 参考 1. Leetcode_easy_690. Employee Importance; 2. 阅读全文

posted @ 2019-06-26 17:49 鹅要长大 阅读(143) 评论(0) 推荐(0)

【Leetcode_easy】687. Longest Univalue Path
摘要:problem 687. Longest Univalue Path 参考 1. Leetcode_easy_687. Longest Univalue Path; 2. Grandyang; 完 阅读全文

posted @ 2019-06-26 17:47 鹅要长大 阅读(113) 评论(0) 推荐(0)

【Leetcode_easy】686. Repeated String Match
摘要:problem 686. Repeated String Match solution1: 使用string类的find函数; solution2: 其实可以直接算出最多需要增加的个数,即B的长度除以A的长度再加上2,当B小于A的时候,那么可能需要两个A,所以i就是小于等于2,这样每次在t中找B,如 阅读全文

posted @ 2019-06-26 17:46 鹅要长大 阅读(104) 评论(0) 推荐(0)

【Leetcode_easy】682. Baseball Game
摘要:problem 682. Baseball Game solution: 没想到使用vector! 参考 1. Leetcode_easy_682. Baseball Game; 2. Grandyang; 完 阅读全文

posted @ 2019-06-26 17:45 鹅要长大 阅读(167) 评论(0) 推荐(0)

【Leetcode_easy】680. Valid Palindrome II
摘要:problem 680. Valid Palindrome II solution: 不理解判断函数中的节点的问题。。。 参考 1. Leetcode_easy_680. Valid Palindrome II; 2. Grandyang; 3. C++ Easy to Understand Cle 阅读全文

posted @ 2019-06-26 17:44 鹅要长大 阅读(137) 评论(0) 推荐(0)

【Leetcode_easy】674. Longest Continuous Increasing Subsequence
摘要:problem 674. Longest Continuous Increasing Subsequence solution solution2: 参考 1. Leetcode_easy_674. Longest Continuous Increasing Subsequence; 2. Gran 阅读全文

posted @ 2019-06-26 17:22 鹅要长大 阅读(146) 评论(0) 推荐(0)

【Leetcode_easy】671. Second Minimum Node In a Binary Tree
摘要:problem 671. Second Minimum Node In a Binary Tree 参考 1. Leetcode_easy_671. Second Minimum Node In a Binary Tree; 完 阅读全文

posted @ 2019-06-26 17:21 鹅要长大 阅读(120) 评论(0) 推荐(0)

【Leetcode_easy】669. Trim a Binary Search Tree
摘要:problem 669. Trim a Binary Search Tree 参考 1. Leetcode_easy_669. Trim a Binary Search Tree; 完 阅读全文

posted @ 2019-06-26 17:20 鹅要长大 阅读(103) 评论(0) 推荐(0)

【Leetcode_easy】665. Non-decreasing Array
摘要:problem 665. Non-decreasing Array 题意:是否能够将数组转换为非减数组。 solution: 难点在于理解如何对需要修改的元素进行赋值; 参考 1. Leetcode_easy_665. Non-decreasing Array; 完 阅读全文

posted @ 2019-06-26 17:19 鹅要长大 阅读(131) 评论(0) 推荐(0)

【Leetcode_easy】661. Image Smoother
摘要:problem 661. Image Smoother 题意:其实类似于图像处理的均值滤波。 solution: 妙处在于使用了一个dirs变量来计算邻域数值,看起来更简洁! 参考 1. Leetcode_easy_661. Image Smoother; 完 阅读全文

posted @ 2019-06-26 17:15 鹅要长大 阅读(143) 评论(0) 推荐(0)

【Leetcode_easy】657. Robot Return to Origin
摘要:problem 657. Robot Return to Origin 题意: solution1: solution2: 参考 1. Leetcode_easy_657. Robot Return to Origin; 完 阅读全文

posted @ 2019-06-26 17:12 鹅要长大 阅读(154) 评论(0) 推荐(0)

【Leetcode_easy】653. Two Sum IV - Input is a BST
摘要:problem 653. Two Sum IV - Input is a BST 参考 1. Leetcode_easy_653. Two Sum IV - Input is a BST; 完 阅读全文

posted @ 2019-06-26 17:10 鹅要长大 阅读(131) 评论(0) 推荐(0)

【Leetcode_easy】645. Set Mismatch
摘要:problem 645. Set Mismatch 题意: solution1: 统计每个数字出现的次数了,然后再遍历次数数组,如果某个数字出现了两次就是重复数,如果出现了0次,就是缺失数。 注意:如何统计每个数字出现的次数; solution2:相反数; 参考 1. Leetcode_easy_6 阅读全文

posted @ 2019-06-25 18:00 鹅要长大 阅读(166) 评论(0) 推荐(0)

【Leetcode_easy】643. Maximum Average Subarray I
摘要:problem 643. Maximum Average Subarray I 题意:一定长度的子数组的最大平均值。 solution1:计算子数组之后的常用方法是建立累加数组,然后再计算任意一定长度的子数组之和,迭代更新得到最大值。 注意:1)累加数组;2)数值类型; solution2: 子数组 阅读全文

posted @ 2019-06-25 17:59 鹅要长大 阅读(126) 评论(0) 推荐(0)

【Leetcode_easy】637. Average of Levels in Binary Tree
摘要:problem 637. Average of Levels in Binary Tree 参考 1. Leetcode_easy_637. Average of Levels in Binary Tree; 完 阅读全文

posted @ 2019-06-25 17:58 鹅要长大 阅读(126) 评论(0) 推荐(0)

【Leetcode_easy】633. Sum of Square Numbers
摘要:problem 633. Sum of Square Numbers 题意: solution1: 可以从c的平方根,注意即使c不是平方数,也会返回一个整型数。然后我们判断如果 i*i 等于c,说明c就是个平方数,只要再凑个0,就是两个平方数之和,返回 true;如果不等于的话,那么算出差值 c - 阅读全文

posted @ 2019-06-24 13:18 鹅要长大 阅读(275) 评论(0) 推荐(0)

【Leetcode_easy】628. Maximum Product of Three Numbers
摘要:problem 628. Maximum Product of Three Numbers 题意:三个数乘积的最大值; solution1: 如果全是负数,三个负数相乘还是负数,为了让负数最大,那么其绝对值就该最小,而负数排序后绝对值小的都在末尾,所以是末尾三个数字相乘,这个跟全是正数的情况一样。那 阅读全文

posted @ 2019-06-24 11:51 鹅要长大 阅读(198) 评论(0) 推荐(0)

上一页 1 ··· 8 9 10 11 12 13 14 15 16 ··· 19 下一页

导航