Documentation
¶
Overview ¶
https://leetcode.com/problems/add-to-array-form-of-integer/description/
For a non-negative integer X, the array-form of X is an array of its digits in left to right order. For example, if X = 1231, then the array form is [1,2,3,1].
Given the array-form A of a non-negative integer X, return the array-form of the integer X+K.
Example 1:
Input: A = [1,2,0,0], K = 34 Output: [1,2,3,4] Explanation: 1200 + 34 = 1234
Example 2:
Input: A = [2,7,4], K = 181 Output: [4,5,5] Explanation: 274 + 181 = 455
Example 3:
Input: A = [2,1,5], K = 806 Output: [1,0,2,1] Explanation: 215 + 806 = 1021
Example 4:
Input: A = [9,9,9,9,9,9,9,9,9,9], K = 1 Output: [1,0,0,0,0,0,0,0,0,0,0] Explanation: 9999999999 + 1 = 10000000000
Note:
1 <= A.length <= 10000 0 <= A[i] <= 9 0 <= K <= 10000 If A.length > 1, then A[0] != 0 https://leetcode.com/problems/maximum-subarray/#/description
Find the contiguous subarray within an array (containing at least one number) which has the largest sum.
For example, given the array [-2,1,-3,4,-1,2,1,-5,4], the contiguous subarray [4,-1,2,1] has the largest sum = 6.
More practice:
If you have figured out the O(n) solution, try coding another solution using the divide and conquer approach, which is more subtle.
思路:直接开始累加,如果累加的和比当前元素还要小,ignore,开始下一轮查找,和保存在i-1的位置。这样,最后nums中保存了所有的局部最优解。
https://leetcode.com/problems/remove-duplicates-from-sorted-array/#/description
Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length.
Do not allocate extra space for another array, you must do this in place with constant memory.
For example, Given input array nums = [1,1,2],
Your function should return length = 2, with the first two elements of nums being 1 and 2 respectively. It doesn't matter what you leave beyond the new length. 注意:nums需要处理一下,也就是不重复的元素要在前面,重复的需要挪到后面
https://leetcode.com/problems/sum-of-even-numbers-after-queries/description/
We have an array A of integers, and an array queries of queries.
For the i-th query val = queries[i][0], index = queries[i][1], we add val to A[index]. Then, the answer to the i-th query is the sum of the even values of A.
(Here, the given index = queries[i][1] is a 0-based index, and each query permanently modifies the array A.)
Return the answer to all queries. Your answer array should have answer[i] as the answer to the i-th query.
Example 1:
Input: A = [1,2,3,4], queries = [[1,0],[-3,1],[-4,0],[2,3]] Output: [8,6,2,4] Explanation: At the beginning, the array is [1,2,3,4]. After adding 1 to A[0], the array is [2,2,3,4], and the sum of even values is 2 + 2 + 4 = 8. After adding -3 to A[1], the array is [2,-1,3,4], and the sum of even values is 2 + 4 = 6. After adding -4 to A[0], the array is [-2,-1,3,4], and the sum of even values is -2 + 4 = 2. After adding 2 to A[3], the array is [-2,-1,3,6], and the sum of even values is -2 + 6 = 4.
Note:
1 <= A.length <= 10000 -10000 <= A[i] <= 10000 1 <= queries.length <= 10000 -10000 <= queries[i][0] <= 10000 0 <= queries[i][1] < A.length https://leetcode.com/problems/two-sum/#/description
Given an array of integers, return indices of the two numbers such that they add up to a specific target.
You may assume that each input would have exactly one solution, and you may not use the same element twice.
Example: Given nums = [2, 7, 11, 15], target = 9,
Because nums[0] + nums[1] = 2 + 7 = 9, return [0, 1].
Index ¶
Constants ¶
const MaxInt = int(MaxUint >> 1)
const MaxUint = ^uint(0)
const MinInt = -MaxInt - 1
Variables ¶
This section is empty.
Functions ¶
Types ¶
Source Files
¶
- 384.go
- addToArrayForm.go
- arrayPairSum.go
- canPlaceFlowers.go
- checkPossibility.go
- dominantIndex.go
- fairCandySwap.go
- fib.go
- findDisappearedNumbers.go
- findDuplicate.go
- findLengthOfLCIS.go
- findLongestChain.go
- findMaxAverage.go
- findMaxAverage2.go
- findMaxConsecutiveOnes.go
- findMedianSortedArrays.go
- findPairs.go
- findShortestSubArray.go
- findUnsortedSubarray.go
- firstMissingPositive.go
- flipAndInvertImage.go
- floodFill.go
- fourSum.go
- fourSumCount.go
- gameOfLife.go
- generate.go
- generateMatrix.go
- getRow.go
- hasGroupsSizeX.go
- imageSmoother.go
- increasingTriplet.go
- insert.go
- isMonotonic.go
- isOneBitCharacter.go
- isToeplitzMatrix.go
- jump.go
- largestPerimeter.go
- largestRectangleArea.go
- longestConsecutive.go
- majorityElement.go
- majorityElement2.go
- matrixReshape.go
- maxArea.go
- maxAreaOfIsland.go
- maxDistToClosest.go
- maxDistance.go
- maxSubArray.go
- merge.go
- merge2.go
- moveZeroes.go
- nextPermutation.go
- numMagicSquaresInside.go
- numRookCaptures.go
- orangesRotting.go
- pivotIndex.go
- plusOne.go
- productExceptSelf.go
- removeDuplicates.go
- removeDuplicates2.go
- removeElement.go
- rotate.go
- rotate2.go
- searchInsert.go
- setZeroes.go
- sortArrayByParity.go
- sortArrayByParityII.go
- sortColors.go
- sortedSquares.go
- spiralOrder.go
- sumEvenAfterQueries.go
- summaryRanges.go
- thirdMax.go
- threeSum.go
- threeSumClosest.go
- topKFrequent.go
- transpose.go
- trap.go
- twoSum.go
- twoSum2.go
- validMountainArray.go