摘要:problem 703. Kth Largest Element in a Stream 题意: solution1: priority_queue这个类型没有看明白。。。 参考 1. Leetcode_easy_703. Kth Largest Element in a Stream; 2. Gr
阅读全文
摘要:problem 700. Search in a Binary Search Tree 参考1. Leetcode_easy_700. Search in a Binary Search Tree; 完
阅读全文
摘要:problem 697. Degree of an Array 题意:首先是原数组的度,其次是和原数组具有相同的度的最短子数组。那么最短子数组就相当于子数组的首末数字都是统计度的数字。 solution1: solution2: 参考 1. Leetcode_easy_697. Degree of
阅读全文
摘要:problem 696. Count Binary Substrings 题意:具有相同个数的1和0的连续子串的数目; solution1:还不是特别理解。。。 遍历元数组,如果是第一个数字,那么对应的ones或zeros自增1。然后进行分情况讨论,如果当前数字是1,然后判断如果前面的数字也是1,则
阅读全文
摘要:problem 693. Binary Number with Alternating Bits solution1: solution2: 通过异或操作判断最低位是否在0/1之间转换进行。 参考 1. Leetcode_easy_693. Binary Number with Alternatin
阅读全文
摘要:problem 690. Employee Importance 题意:所有下属和自己的重要度之和,所有下属包括下属的下属即直接下属和间接下属。 solution:DFS; solution:BFS; 参考 1. Leetcode_easy_690. Employee Importance; 2.
阅读全文
摘要:problem 687. Longest Univalue Path 参考 1. Leetcode_easy_687. Longest Univalue Path; 2. Grandyang; 完
阅读全文
摘要:problem 686. Repeated String Match solution1: 使用string类的find函数; solution2: 其实可以直接算出最多需要增加的个数,即B的长度除以A的长度再加上2,当B小于A的时候,那么可能需要两个A,所以i就是小于等于2,这样每次在t中找B,如
阅读全文
摘要:problem 682. Baseball Game solution: 没想到使用vector! 参考 1. Leetcode_easy_682. Baseball Game; 2. Grandyang; 完
阅读全文
摘要:problem 680. Valid Palindrome II solution: 不理解判断函数中的节点的问题。。。 参考 1. Leetcode_easy_680. Valid Palindrome II; 2. Grandyang; 3. C++ Easy to Understand Cle
阅读全文
摘要:problem 674. Longest Continuous Increasing Subsequence solution solution2: 参考 1. Leetcode_easy_674. Longest Continuous Increasing Subsequence; 2. Gran
阅读全文
摘要:problem 671. Second Minimum Node In a Binary Tree 参考 1. Leetcode_easy_671. Second Minimum Node In a Binary Tree; 完
阅读全文
摘要:problem 669. Trim a Binary Search Tree 参考 1. Leetcode_easy_669. Trim a Binary Search Tree; 完
阅读全文
摘要:problem 665. Non-decreasing Array 题意:是否能够将数组转换为非减数组。 solution: 难点在于理解如何对需要修改的元素进行赋值; 参考 1. Leetcode_easy_665. Non-decreasing Array; 完
阅读全文
摘要:problem 661. Image Smoother 题意:其实类似于图像处理的均值滤波。 solution: 妙处在于使用了一个dirs变量来计算邻域数值,看起来更简洁! 参考 1. Leetcode_easy_661. Image Smoother; 完
阅读全文
摘要:problem 657. Robot Return to Origin 题意: solution1: solution2: 参考 1. Leetcode_easy_657. Robot Return to Origin; 完
阅读全文
摘要:problem 653. Two Sum IV - Input is a BST 参考 1. Leetcode_easy_653. Two Sum IV - Input is a BST; 完
阅读全文
摘要:problem 645. Set Mismatch 题意: solution1: 统计每个数字出现的次数了,然后再遍历次数数组,如果某个数字出现了两次就是重复数,如果出现了0次,就是缺失数。 注意:如何统计每个数字出现的次数; solution2:相反数; 参考 1. Leetcode_easy_6
阅读全文
摘要:problem 643. Maximum Average Subarray I 题意:一定长度的子数组的最大平均值。 solution1:计算子数组之后的常用方法是建立累加数组,然后再计算任意一定长度的子数组之和,迭代更新得到最大值。 注意:1)累加数组;2)数值类型; solution2: 子数组
阅读全文
摘要:problem 637. Average of Levels in Binary Tree 参考 1. Leetcode_easy_637. Average of Levels in Binary Tree; 完
阅读全文
摘要:problem 633. Sum of Square Numbers 题意: solution1: 可以从c的平方根,注意即使c不是平方数,也会返回一个整型数。然后我们判断如果 i*i 等于c,说明c就是个平方数,只要再凑个0,就是两个平方数之和,返回 true;如果不等于的话,那么算出差值 c -
阅读全文
摘要:problem 628. Maximum Product of Three Numbers 题意:三个数乘积的最大值; solution1: 如果全是负数,三个负数相乘还是负数,为了让负数最大,那么其绝对值就该最小,而负数排序后绝对值小的都在末尾,所以是末尾三个数字相乘,这个跟全是正数的情况一样。那
阅读全文
摘要:problem 617. Merge Two Binary Trees 参考 1. Leetcode_easy_617. Merge Two Binary Trees; 完 完
阅读全文
摘要:problem 606. Construct String from Binary Tree 参考 1. Leetcode_easy_606. Construct String from Binary Tree; 完
阅读全文
摘要:problem 605. Can Place Flowers 题意: solution1: 先通过简单的例子(比如000)发现,通过计算连续0的个数,然后直接算出能放花的个数,就必须要对边界进行处理,处理方法是如果首位置是0,那么前面再加上个0,如果末位置是0,就在最后面再加上个0。这样处理之后就默
阅读全文
摘要:problem 599. Minimum Index Sum of Two Lists 题意:给出两个字符串数组,找到坐标位置之和最小的相同的字符串。 计算两个的坐标之和,如果与最小坐标和sum相同,那么将这个字符串加入结果res中,如果比sum小,那么sum更新为这个较小值,然后将结果res清空并
阅读全文
摘要:problem 598. Range Addition II 题意: 第一感觉就是最小的行和列的乘积即是最后结果。 参考 1. Leetcode_easy_598. Range Addition II; 2. Grandyang; 完
阅读全文
摘要:problem 594. Longest Harmonious Subsequence 最长和谐子序列 题意: 可以对数组进行排序,那么实际上只要找出来相差为1的两个数的总共出现个数就是一个和谐子序列的长度了. solution1: 使用hashmap 用 HashMap 来做,先遍历一遍,建立每个
阅读全文
摘要:problem 590. N-ary Tree Postorder Traversal 参考 1. Leetcode_easy_590. N-ary Tree Postorder Traversal; 完
阅读全文
摘要:problem 589. N-ary Tree Preorder Traversal N叉树的前序遍历 首先复习一下树的4种遍历,前序、中序、后序和层序。其中,前序、中序和后序是根据根节点的顺序进行区分和命名的。 层序遍历,即是按树的层从上到下、从左到右进行遍历。 参考 1. Leetcode_ea
阅读全文
摘要:method: 参考 1. Ubuntu下的终端多标签切换快捷键; 完
阅读全文
摘要:re1. github_lane_detection; end
阅读全文
摘要:re 1. struct timespec 和 struct timeval; end
阅读全文
摘要:OpenCV中image.copyTo()有两种形式: 1、image.copyTo(imageROI),作用是把image的内容粘贴到imageROI; 2、image.copyTo(imageROI,mask),作用是把mask和image重叠以后把mask中像素值为0(black)的点对应的i
阅读全文
摘要:re 1. C++关键字之friend; end 希望大家能把自己的所学和他人一起分享,不要去鄙视别人索取时的贪婪,因为最应该被鄙视的是不肯分享时的吝啬。 GOOD
阅读全文
摘要:问题描述 打开d2l-zh目录,使用jupyter notebook打开文件运行,import mxnet 出现无法导入mxnet模块的问题, 但是命令行运行是可以导入mxnet模块的。 原因: 激活环境是能够运行代码的前提。 解决方法: 在d2l-zh目录运行conda activate gluo
阅读全文
摘要:opencv-split Divides a multi-channel array into several single-channel arrays. code 参考 1. opencv_split; 完
阅读全文
摘要:problem 581. Shortest Unsorted Continuous Subarray 题意:感觉题意理解的不是非常明白。 solution1: 使用一个辅助数组,新建一个跟原数组一模一样的数组,然后排序。从数组起始位置开始,两个数组相互比较,当对应位置数字不同的时候停止,同理再从末尾
阅读全文
摘要:problem 577. Employee Bonus 参考 1. Leetcode_easy_$_577. Employee Bonus; 2. https://www.cnblogs.com/lightwindy/p/9698931.html; 完
阅读全文
摘要:problem 575. Distribute Candies 理解题意:主要是计算candies的种类数。 如果大于candies数目的一半,则返回一半的值,否则,返回candies的种类数。 solution1: 注意掌握set的用法; solution2: re 1. Leetcode_eas
阅读全文
摘要:problem 572. Subtree of Another Tree re 1. Leetcode_easy_572. Subtree of Another Tree; end
阅读全文
摘要:problem 566. Reshape the Matrix solution solution2 re 1. Leetcode_easy_566. Reshape the Matrix; 2. Grandyang; end
阅读全文
摘要:problem 563. Binary Tree Tilt re 1. Leetcode_easy_563. Binary Tree Tilt; end
阅读全文
摘要:problem 561. Array Partition I solution re 1. Leetcode_easy_561. Array Partition I; 2. Grandyang; end
阅读全文
摘要:problem 559. Maximum Depth of N-ary Tree re 1. Leetcode_easy_559. Maximum Depth of N-ary Tree; end
阅读全文