摘要:problem 1030. Matrix Cells in Distance Order solution#1: 排序; code solution#2: code 参考 1. leetcode_easy_sort_1030. Matrix Cells in Distance Order; 2. s
阅读全文
摘要:problem 1356. Sort Integers by The Number of 1 Bits solution#1: code: 注意,先按照数字1的数目排序,若相等,则按照整数的大小排序; 参考 1. leetcode_easy_sort_1356. Sort Integers by T
阅读全文
摘要:problem 883. Projection Area of 3D Shapes solution#1: code 注意求解各行的最大值之和,以及各列的最大值之和; 参考 1. leetcode_easy_math_883. Projection Area of 3D Shapes; 2. Gra
阅读全文
摘要:leetcode_easy_array problem 1475. Final Prices With a Special Discount in a Shop solution #1: 使用新数组更新数据; code solution #2: 直接在原数组更新数据; code: 注意: 1. 满足
阅读全文
摘要:leetcode_easy_array problem 1486. XOR Operation in an Array solution #1: code: 参考 1. leetcode_1486. XOR Operation in an Array; 完
阅读全文
摘要:leetcode_easy_array 1491. Average Salary Excluding the Minimum and Maximum Salary solution #1: code solution #2: code 注意: 1. 去除最大最小值之后的平均值; 2. 数组元素是un
阅读全文
摘要:leetcode_easy_array problem 1480. Running Sum of 1d Array solution #1: code: 参考 1. leetcode_1480. Running Sum of 1d Array; 完
阅读全文
摘要:leetcode_easy_array problem 1470. Shuffle the Array solution #1: code solution #2: code 注意: 1. vector; first, last Input iterators to the initial and
阅读全文
摘要:leetcode_easy_array 1464. Maximum Product of Two Elements in an Array solution #1: code: 参考 1. leetcode_1464. Maximum Product of Two Elements in an Ar
阅读全文
摘要:leetcode_medium_array problem 18. 4Sum solution #1: code 注意: 1. 和3Sum的题目思路基本一致,多了一层循环,使用双指针; 参考 1. leetcode_18. 4Sum; 2. Grandyang; 完
阅读全文
摘要:leetcode_medium_array problem 16. 3Sum Closest solution #1: 三重循环; code: solution #2: 排序后通过双指针移动确定; code 参考 1. leetcode_16. 3Sum Closest; 完
阅读全文
摘要:leetcode_medium_array problem 11. Container With Most Water solution #1: code 参考 1. leetcode_11. Container With Most Water; 完
阅读全文
摘要:leetcode_medium_array problem 15. 3Sum 注意: 1. 题目要求的没有重复的三元组,是指三元组是不同的,但是三元组的元素是可能有相同的; 2. 参考 1. leetcode_15. 3Sum; 2. Grandyang; 完
阅读全文
摘要:leetcode_medium_array problem 31. Next Permutation solution #1: According to Wikipedia, a man named Narayana Pandita presented the following simple al
阅读全文
摘要:leetcode_easy_array problem 1460. Make Two Arrays Equal by Reversing Sub-arrays solution #1: code: 参考 1. leetcode_1460. Make Two Arrays Equal by Rever
阅读全文
摘要:leetcode_easy_array 1502. Can Make Arithmetic Progression From Sequence solution #1: code 参考 1. leetcode_1502. Can Make Arithmetic Progression From Se
阅读全文
摘要:1588. Sum of All Odd Length Subarrays solution#1: Brute Search; code solution#2: 元素求和; code solution#3: 找规律; code: 参考 1. leetcode_easy_array_1588. Sum
阅读全文
摘要:leetcode_medium_array problem 33. Search in Rotated Sorted Array solution #1: 解题思路: 先使用二分法找出最小的元素,然后确定哪一边进行搜索,最后使用二分法搜索; code: 注意: 1. 二分法的思路和code必须熟练掌
阅读全文
摘要:leetcode_medium_array problem 34. Find First and Last Position of Element in Sorted Array solution #1: 解题思路:分别使用二分法查找最左和最右端的元素; code 注意,最右端元素的mid值如何确定
阅读全文
摘要:leetcode_medium_array problem 39. Combination Sum 看过别人的解法还是没有完全明白。。。 solution #1: 使用递归函数; code: solution #2: 数组排序后使用递归函数; code 注意: 1. 参考 1. leetcode_3
阅读全文