摘要: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
阅读全文
摘要: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
阅读全文
摘要:problem 558. Quad Tree Intersection re 1. Leetcode_easy_558. Quad Tree Intersection; 2. Grandyang; end
阅读全文
摘要:problem 557. Reverse Words in a String III solution1:字符流处理类istringstream. solution2:单词首尾指针。 参考 1. Leetcode_easy_557. Reverse Words in a String III; 2.
阅读全文
摘要:problem 551. Student Attendance Record I 题意: solution: 理解题意很简单,重要的是其中的逻辑怎么实现。还有一点需要注意自加自减运算,感觉还是有点不熟练。。 参考 1. Leetcode_easy_551. Student Attendance Re
阅读全文
摘要:problem 543. Diameter of Binary Tree 题意: 转换一种角度来看,是不是其实就是根结点1的左右两个子树的深度之和呢。那么我们只要对每一个结点求出其左右子树深度之和,这个值作为一个候选值,然后再对左右子结点分别调用求直径对递归函数,这三个值相互比较,取最大的值更新结果
阅读全文