摘要:problem 748. Shortest Completing Word 题意: solution1: class Solution { public: string shortestCompletingWord(string licensePlate, vector<string>& words
阅读全文
摘要:problem 754. Reach a Number solution1: solution2: solution3:solution1的精简版; 参考 1. Leetcode_easy_754. Reach a Number; 2. Grandyang; 完
阅读全文
摘要:problem 747. Largest Number At Least Twice of Others 题意: solution1: solution2: 参考 1. Leetcode_easy_747. Largest Number At Least Twice of Others; 2. Gr
阅读全文
摘要:problem 1089. Duplicate Zeros 题意: solution: 其中关于虚拟新数组的下标的计算还是有点迷糊。。。 参考 1. Leetcode_easy_1089. Duplicate Zeros; 2. discuss; 完
阅读全文
摘要:problem 1103. Distribute Candies to People solution:没看明白代码。。。 参考 1. Leetcode_easy_1103. Distribute Candies to People; 2. Discuss; 完
阅读全文
摘要:problem 1108. Defanging an IP Address solution: 参考 1. Leetcode_easy_1108. Defanging an IP Address; 完
阅读全文
摘要:problem 746. Min Cost Climbing Stairs 题意: solution1:动态规划; 定义一个一维的dp数组,其中dp[i]表示爬到第i层的最小cost,然后来想dp[i]如何推导。思考一下如何才能到第i层呢?是不是只有两种可能性,一个是从第i-2层上直接跳上来,一个是
阅读全文
摘要:problem 744. Find Smallest Letter Greater Than Target 题意:一堆有序的字母,然后又给了一个target字母,让求字母数组中第一个大于target的字母,数组是循环的,如果没有,那就返回第一个字母。 solution1:注意数组已经是有序数组啦。。
阅读全文
摘要:problem 733. Flood Fill 题意:图像处理中的泛洪填充算法,常见的有四邻域像素填充法、八邻域像素填充法、基于扫描线的像素填充法,实现方法分为递归与非递归(基于栈)。 泛洪填充算法原理:从某个像素点开始,将封闭区域内的所有此像素值位置的元素填充为新颜色。 solution1: 递归
阅读全文
摘要:problem 728. Self Dividing Numbers solution1: 使用string类型来表示每位上的数字; solution2: 使用数学计算来check每一个数字; 问题1:求解余数的语句; 问题2:需要先求解一次余数,再计算除数,即下一次计算需要用到的被除数。 参考 1
阅读全文
摘要:problem 724. Find Pivot Index 题意:先求出数组的总和,然后维护一个当前数组之和curSum,然后对于遍历到的位置,用总和减去当前数字,看得到的结果是否是curSum的两倍,是的话,那么当前位置就是中枢点,返回即可;否则就将当前数字加到curSum中继续遍历,遍历结束后还
阅读全文
摘要:problem 720. Longest Word in Dictionary 题意: solution1: BFS; solution2: 参考 1. Leetcode_easy_720. Longest Word in Dictionary; 2. Grandyang; 完
阅读全文
摘要:problem 717. 1-bit and 2-bit Characters 题意:solution1: solution2:根据数组的特性计算。 参考 1. Leetcode_easy_717. 1-bit and 2-bit Characters; 2. Grandyang; 完
阅读全文
摘要:problem 709. To Lower Case solution1: solution2: 参考 1. Leetcode_easy_709. To Lower Case; 2. Grandyang; 完
阅读全文
摘要:problem 707. Design Linked List 参考 1. Leetcode_easy_707. Design Linked List; 完
阅读全文
摘要:problem 706. Design HashMap solution1: solution2: 参考 1. Leetcode_easy_706. Design HashMap; 2. Grandyang; 完
阅读全文
摘要:problem 705. Design HashSet 题意: solution1: solution2: 参考 1. Leetcode_easy_705. Design HashSet; 2. Grandyang; 完
阅读全文
摘要:problem 704. Binary Search solution: 参考 1. Leetcode_easy_704. Binary Search; 完
阅读全文
摘要: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; 完
阅读全文