206. Reverse Linked List

206. Reverse Linked List Given the head of a singly linked list, reverse the list, and return the reversed list. 1 2 3 4 Example 1: Input: head = [1,2,3,4,5] Output: [5,4,3,2,1] 1 2 3 4 Example 2: Input: head = [1,2] Output: [2,1] 1 2 3 4 Example 3: Input: head = [] Output: [] Constraints: The number of nodes in the list is the range [0, 5000]. -5000 <= Node....

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

24. Swap Nodes in Pairs

24. Swap Nodes in Pairs Given a linked list, swap every two adjacent nodes and return its head. You must solve the problem without modifying the values in the list’s nodes (i.e., only nodes themselves may be changed.) 1 2 3 4 Example 1: Input: head = [1,2,3,4] Output: [2,1,4,3] 1 2 3 4 5 6 7 8 9 Example 2: Input: head = [] Output: [] Example 3: Input: head = [1] Output: [1] Constraints:...

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

237. Delete Node in a Linked List

237. Delete Node in a Linked List Write a function to delete a node in a singly-linked list. You will not be given access to the head of the list, instead you will be given access to the node to be deleted directly. It is guaranteed that the node to be deleted is not a tail node in the list. 1 2 3 4 5 Example 1: Input: head = [4,5,1,9], node = 5 Output: [4,1,9] Explanation: You are given the second node with value 5, the linked list should become 4 -> 1 -> 9 after calling your function....

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

680. Valid Palindrome II

680. Valid Palindrome II Given a string s, return true if the s can be palindrome after deleting at most one character from it. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Example 1: Input: s = "aba" Output: true Example 2: Input: s = "abca" Output: true Explanation: You could delete the character 'c'. Example 3: Input: s = "abc" Output: false Constraints:...

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

1099. Two Sum Less Than K

1099. Two Sum Less Than K Given an array nums of integers and integer k, return the maximum sum such that there exists i < j with nums[i] + nums[j] = sum and sum < k. If no i, j exist satisfying this equation, return -1. 1 2 3 4 5 6 7 8 9 10 11 Example 1: Input: nums = [34,23,1,24,75,33,54,8], k = 60 Output: 58 Explanation: We can use 34 and 24 to sum 58 which is less than 60....

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

19. Remove Nth Node From End of List

19. Remove Nth Node From End of List Given the head of a linked list, remove the nth node from the end of the list and return its head. 1 2 3 4 Example 1: Input: head = [1,2,3,4,5], n = 2 Output: [1,2,3,5] 1 2 3 4 5 6 7 8 9 Example 2: Input: head = [1], n = 1 Output: [] Example 3: Input: head = [1,2], n = 1 Output: [1] Constraints:...

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

2. Add Two Numbers

2. Add Two Numbers You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order, and each of their nodes contains a single digit. Add the two numbers and return the sum as a linked list. You may assume the two numbers do not contain any leading zero, except the number 0 itself. 1 2 3 4 5 Example 1: Input: l1 = [2,4,3], l2 = [5,6,4] Output: [7,0,8] Explanation: 342 + 465 = 807....

<span title='2021-06-14 00:00:00 +0000 UTC'>June 14, 2021</span>&nbsp;·&nbsp;4 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

67. Add Binary

67. Add Binary Given two binary strings a and b, return their sum as a binary string. 1 2 3 4 5 6 7 8 9 Example 1: Input: a = "11", b = "1" Output: "100" Example 2: Input: a = "1010", b = "1011" Output: "10101" Constraints: 1 <= a.length, b.length <= 104 a and b consist only of ‘0’ or ‘1’ characters. Each string does not contain leading zeros except for the zero itself....

<span title='2021-06-14 00:00:00 +0000 UTC'>June 14, 2021</span>&nbsp;·&nbsp;2 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

1897. Redistribute Characters to Make All Strings Equal

1897. Redistribute Characters to Make All Strings Equal You are given an array of strings words (0-indexed). In one operation, pick two distinct indices i and j, where words[i] is a non-empty string, and move any character from words[i] to any position in words[j]. Return true if you can make every string in words equal using any number of operations, and false otherwise. 1 2 3 4 5 6 7 8 9 10 11 12 13 Example 1: Input: words = ["abc","aabc","bc"] Output: true Explanation: Move the first 'a' in words[1] to the front of words[2], to make words[1] = "abc" and words[2] = "abc"....

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

1898. Maximum Number of Removable Characters

1898. Maximum Number of Removable Characters You are given two strings s and p where p is a subsequence of s. You are also given a distinct 0-indexed integer array removable containing a subset of indices of s (s is also 0-indexed). You want to choose an integer k (0 <= k <= removable.length) such that, after removing k characters from s using the first k indices in removable, p is still a subsequence of s....

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

1899. Merge Triplets to Form Target Triplet

1899. Merge Triplets to Form Target Triplet A triplet is an array of three integers. You are given a 2D integer array triplets, where triplets[i] = [ai, bi, ci] describes the ith triplet. You are also given an integer array target = [x, y, z] that describes the triplet you want to obtain. To obtain target, you may apply the following operation on triplets any number of times (possibly zero):...

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

31. Next Permutation

31. Next Permutation Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers. If such an arrangement is not possible, it must rearrange it as the lowest possible order (i.e., sorted in ascending order). The replacement must be in place and use only constant extra memory. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 Example 1: Input: nums = [1,2,3] Output: [1,3,2] Example 2: Input: nums = [3,2,1] Output: [1,2,3] Example 3: Input: nums = [1,1,5] Output: [1,5,1] Example 4: Input: nums = [1] Output: [1] Constraints:...

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

338. Counting Bits"

338. Counting Bits Given an integer n, return an array ans of length n + 1 such that for each i (0 <= i <= n), ans[i] is the number of 1’s in the binary representation of i. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 Example 1: Input: n = 2 Output: [0,1,1] Explanation: 0 --> 0 1 --> 1 2 --> 10 Example 2: Input: n = 5 Output: [0,1,1,2,1,2] Explanation: 0 --> 0 1 --> 1 2 --> 10 3 --> 11 4 --> 100 5 --> 101 Constraints:...

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