整个数组的和(sum)是可以很容易得到的,那么分成两个部分,每个部分的和(sum/2)也就可以很容易得到了。于是这道题就变成了,能不能从数组中找出一些数,使之和为 sum/2?搜索求解即可。 求解期间做一点小优化,创建一个<index, <target, partitionable>> 这样的结构,表示源数组的下标 index 开始往后到底的这一段...
Target Sum 45.7%Medium 538 Convert BST to Greater Tree 52.1%Easy 543 Diameter of Binary Tree 47.3%Easy 560 Subarray Sum Equals K 42.8%Medium 581 Shortest Unsorted Continuous Subarray 30.4%Easy 617 Merge Two Binary Trees 71.0%Easy 621
1300 Sum of Mutated Array Closest to Target 43.10% Medium 1299 Replace Elements with Greatest Element on Right Side 74.70% Easy 1298 Maximum Candies You Can Get from Boxes 60.90% Hard 1297 Maximum Number of Occurrences of a Substring 52.00% Medium 1296 Divide Array in Sets of K Consecutive Nu...
0325 Maximum Size Subarray Sum Equals k 46.8% Medium 0326 Power of Three Go 42.1% Easy 0327 Count of Range Sum Go 35.1% Hard 0328 Odd Even Linked List Go 55.7% Medium 0329 Longest Increasing Path in a Matrix Go 43.4% Hard 0330 Patching Array 34.5% Hard 0331 Verify Preorder Se...
给出二叉 搜索 树的根节点,该树的节点值各不相同,请你将其转换为累加树(Greater Sum Tree),使每个节点 node 的新值等于原树中大于或等于 node.val 的值之和。 提醒一下,二叉搜索树满足下列约束条件: 节点的左子树仅包含键 小于 节点键的节点。
560 Subarray Sum Equals K Solution O(n) O(n) Medium Array, HashMap 561 Array Partition I Solution O(nlogn) O(1) Easy Array 562 Longest Line of Consecutive One in Matrix Solution O(m*n) O(m*n) Medium Matrix DP 563 Binary Tree Tilt Solution O(n) O(n) Easy Tree Recursion 565 ...
327 Count of Range Sum 24.30% Hard 326 Power of Three 35.30% Easy 325 Maximum Size Subarray Sum Equals k $ 39.60% Easy 324 Wiggle Sort II 20.10% Medium 323 Number of Connected Components in an Undirected Graph $ 43.30% Medium 322 Coin Change 24.90% Medium 321 Create Maximum Number 19.10...
https://leetcode-cn.com/problems/partition-equal-subset-sum/ 494. 目标和 中等 https://leetcode-cn.com/problems/target-sum/ 十九、记忆化搜索 312. 戳气球 困难 https://leetcode-cn.com/problems/burst-balloons/ 322. 零钱兑换 中等 https://leetcode-cn.com/problems/coin-change/ ...
560 Subarray Sum Equals K 41.80% Medium 561 Array Partition I 69.80% Easy 562 Longest Line of Consecutive One in Matrix $ 38.80% Medium 563 Binary Tree Tilt 47.00% Easy 564 Find the Closest Palindrome 16.60% Hard 565 Array Nesting 50.00% Medium 566 Reshape the Matrix 59.80% Easy 567 Permut...
Sum of Mutated Array Closest to Target Leetcode 1060. Missing Element in Sorted Array 双指针(2 Pointer): 基础知识:常见双指针算法分为三类,同向(即两个指针都相同一个方向移动),背向(两个指针从相同或者相邻的位置出发,背向移动直到其中一根指针到达边界为止),相向(两个指针从两边出发一起向中间移动直到...