1423. Maximum Points You Can Obtain from Cards

There are several cards arranged in a row, and each card has an associated number of points. The points are given in the integer array cardPoints. In one step, you can take one card from the beginning or from the end of the row. You have to take exactly k cards. Your score is the sum of the points of the cards you have taken. Given the integer array cardPoints and the integer k, return the maximum score you can obtain....

<span title='2021-12-06 00:00:00 +0000 UTC'>December 6, 2021</span>&nbsp;·&nbsp;3 min&nbsp;·&nbsp;volyx

1546. Maximum Number of Non-Overlapping Subarrays With Sum Equals Target

Given an array nums and an integer target. Return the maximum number of non-empty non-overlapping subarrays such that the sum of values in each subarray is equal to target. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 Example 1: Input: nums = [1,1,1,1,1], target = 2 Output: 2 Explanation: There are 2 non-overlapping subarrays [1,1,1,1,1] with sum equals to target(2)....

<span title='2021-10-16 00:00:00 +0000 UTC'>October 16, 2021</span>&nbsp;·&nbsp;2 min&nbsp;·&nbsp;volyx

303. Range Sum Query - Immutable

303. Range Sum Query - Immutable Given an integer array nums, handle multiple queries of the following type: Calculate the sum of the elements of nums between indices left and right inclusive where left <= right. Implement the NumArray class: NumArray(int[] nums) Initializes the object with the integer array nums. int sumRange(int left, int right) Returns the sum of the elements of nums between indices left and right inclusive (i.e. nums[left] + nums[left + 1] + … + nums[right])....

<span title='2021-07-20 00:00:00 +0000 UTC'>July 20, 2021</span>&nbsp;·&nbsp;3 min&nbsp;·&nbsp;volyx

523. Continuous Subarray Sum

523. Continuous Subarray Sum Given an integer array nums and an integer k, return true if nums has a continuous subarray of size at least two whose elements sum up to a multiple of k, or false otherwise. An integer x is a multiple of k if there exists an integer n such that x = n * k. 0 is always a multiple of k. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 Example 1: Input: nums = [23,2,4,6,7], k = 6 Output: true Explanation: [2, 4] is a continuous subarray of size 2 whose elements sum up to 6....

<span title='2021-06-14 00:00:00 +0000 UTC'>June 14, 2021</span>&nbsp;·&nbsp;3 min&nbsp;·&nbsp;volyx

974. Subarray Sums Divisible by K

974. Subarray Sums Divisible by K Given an array nums of integers, return the number of (contiguous, non-empty) subarrays that have a sum divisible by k. 1 2 3 4 5 6 Example 1: Input: nums = [4,5,0,-2,-3,1], k = 5 Output: 7 Explanation: There are 7 subarrays with a sum divisible by k = 5: [4, 5, 0, -2, -3, 1], [5], [5, 0], [5, 0, -2, -3], [0], [0, -2, -3], [-2, -3] Note:...

<span title='2021-06-14 00:00:00 +0000 UTC'>June 14, 2021</span>&nbsp;·&nbsp;1 min&nbsp;·&nbsp;volyx

1365. How Many Numbers Are Smaller Than the Current Number

1365. How Many Numbers Are Smaller Than the Current Number Given the array nums, for each nums[i] find out how many numbers in the array are smaller than it. That is, for each nums[i] you have to count the number of valid j’s such that j != i and nums[j] < nums[i]. Return the answer in an array. 1 2 3 4 5 6 7 8 9 10 Example 1: Input: nums = [8,1,2,2,3] Output: [4,0,1,1,3] Explanation: For nums[0]=8 there exist four smaller numbers than it (1, 2, 2 and 3)....

<span title='2021-04-17 00:00:00 +0000 UTC'>April 17, 2021</span>&nbsp;·&nbsp;2 min&nbsp;·&nbsp;volyx

560. Subarray Sum Equals K

Given an array of integers and an integer k, you need to find the total number of continuous subarrays whose sum equals to k. Example 1: Input:nums = [1,1,1], k = 2 Output: 2 Note: The length of the array is in range [1, 20,000]. The range of numbers in the array is [-1000, 1000] and the range of the integer k is [-1e7, 1e7]. Hints 1 2 3 4 5 6 7 8 Hide Hint #1 Will Brute force work here?...

<span title='2020-04-28 00:00:00 +0000 UTC'>April 28, 2020</span>&nbsp;·&nbsp;2 min&nbsp;·&nbsp;volyx