1090. Largest Values From Labels

![https://leetcode.com/problems/largest-values-from-labels/] We have a set of items: the i-th item has value values[i] and label labels[i]. Then, we choose a subset S of these items, such that: |S| <= num_wanted For every label L, the number of items in S with label L is <= use_limit. Return the largest possible sum of the subset S. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 Example 1: Input: values = [5,4,3,2,1], labels = [1,1,2,2,3], num_wanted = 3, use_limit = 1 Output: 9 Explanation: The subset chosen is the first, third, and fifth item....

<span title='2021-03-01 00:00:00 +0000 UTC'>March 1, 2021</span>&nbsp;·&nbsp;3 min&nbsp;·&nbsp;volyx

240. Search a 2D Matrix II

![https://leetcode.com/problems/search-a-2d-matrix-ii/] Write an efficient algorithm that searches for a target value in an m x n integer matrix. The matrix has the following properties: Integers in each row are sorted in ascending from left to right. Integers in each column are sorted in ascending from top to bottom. 1 2 3 4 Example 1: Input: matrix = [[1,4,7,11,15],[2,5,8,12,19],[3,6,9,16,22],[10,13,14,17,24],[18,21,23,26,30]], target = 5 Output: true 1 2 3 4 Example 2: Input: matrix = [[1,4,7,11,15],[2,5,8,12,19],[3,6,9,16,22],[10,13,14,17,24],[18,21,23,26,30]], target = 20 Output: false Constraints:...

<span title='2021-03-01 00:00:00 +0000 UTC'>March 1, 2021</span>&nbsp;·&nbsp;1 min&nbsp;·&nbsp;volyx

1637. Widest Vertical Area Between Two Points Containing No Points

![https://leetcode.com/problems/widest-vertical-area-between-two-points-containing-no-points/] Given n points on a 2D plane where points[i] = [xi, yi], Return the widest vertical area between two points such that no points are inside the area. A vertical area is an area of fixed-width extending infinitely along the y-axis (i.e., infinite height). The widest vertical area is the one with the maximum width. Note that points on the edge of a vertical area are not considered included in the area....

<span title='2021-02-26 00:00:00 +0000 UTC'>February 26, 2021</span>&nbsp;·&nbsp;2 min&nbsp;·&nbsp;volyx

973. K Closest Points to Origin

![https://leetcode.com/problems/k-closest-points-to-origin/] We have a list of points on the plane. Find the K closest points to the origin (0, 0). (Here, the distance between two points on a plane is the Euclidean distance.) You may return the answer in any order. The answer is guaranteed to be unique (except for the order that it is in.) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Example 1: Input: points = [[1,3],[-2,2]], K = 1 Output: [[-2,2]] Explanation: The distance between (1, 3) and the origin is sqrt(10)....

<span title='2021-02-26 00:00:00 +0000 UTC'>February 26, 2021</span>&nbsp;·&nbsp;6 min&nbsp;·&nbsp;volyx

169. Majority Element

![https://leetcode.com/problems/majority-element/] Given an array nums of size n, return the majority element. The majority element is the element that appears more than ⌊n / 2⌋ times. You may assume that the majority element always exists in the array. 1 2 3 4 5 6 7 8 9 Example 1: Input: nums = [3,2,3] Output: 3 Example 2: Input: nums = [2,2,1,1,1,2,2] Output: 2 Constraints: n == nums.length 1 <= n <= 5 * 104 -231 <= nums[i] <= 231 - 1 Follow-up: Could you solve the problem in linear time and in O(1) space?...

<span title='2021-02-25 00:00:00 +0000 UTC'>February 25, 2021</span>&nbsp;·&nbsp;2 min&nbsp;·&nbsp;volyx

215. Kth Largest Element in an Array

![https://leetcode.com/problems/kth-largest-element-in-an-array/] Find the kth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct element. 1 2 3 4 5 6 7 8 9 Example 1: Input: [3,2,1,5,6,4] and k = 2 Output: 5 Example 2: Input: [3,2,3,1,2,4,5,5,6] and k = 4 Output: 4 Note: You may assume k is always valid, 1 ≤ k ≤ array’s length. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 class Solution { public int findKthLargest(int[] nums, int k) { int lo = 0; int hi = nums....

<span title='2021-02-24 00:00:00 +0000 UTC'>February 24, 2021</span>&nbsp;·&nbsp;2 min&nbsp;·&nbsp;volyx

1528. Shuffle String

![https://leetcode.com/problems/shuffle-string/] Given a string s and an integer array indices of the same length. The string s will be shuffled such that the character at the ith position moves to indices[i] in the shuffled string. Return the shuffled string. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 Example 1: Input: s = "codeleet", indices = [4,5,6,7,0,2,1,3] Output: "leetcode" Explanation: As shown, "codeleet" becomes "leetcode" after shuffling....

<span title='2021-02-23 00:00:00 +0000 UTC'>February 23, 2021</span>&nbsp;·&nbsp;2 min&nbsp;·&nbsp;volyx

1319. Number of Operations to Make Network Connected

![https://leetcode.com/problems/remove-outermost-parentheses/] There are n computers numbered from 0 to n-1 connected by ethernet cables connections forming a network where connections[i] = [a, b] represents a connection between computers a and b. Any computer can reach any other computer directly or indirectly through the network. Given an initial computer network connections. You can extract certain cables between two directly connected computers, and place them between any pair of disconnected computers to make them directly connected....

<span title='2021-02-22 00:00:00 +0000 UTC'>February 22, 2021</span>&nbsp;·&nbsp;4 min&nbsp;·&nbsp;volyx

150. Evaluate Reverse Polish Notation

![https://leetcode.com/problems/evaluate-reverse-polish-notation/] Evaluate the value of an arithmetic expression in Reverse Polish Notation. Valid operators are +, -, *, /. Each operand may be an integer or another expression. Note: Division between two integers should truncate toward zero. The given RPN expression is always valid. That means the expression would always evaluate to a result and there won’t be any divide by zero operation. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 Example 1: Input: ["2", "1", "+", "3", "*"] Output: 9 Explanation: ((2 + 1) * 3) = 9 Example 2: Input: ["4", "13", "5", "/", "+"] Output: 6 Explanation: (4 + (13 / 5)) = 6 Example 3: Input: ["10", "6", "9", "3", "+", "-11", "*", "/", "*", "17", "+", "5", "+"] Output: 22 Explanation: ((10 * (6 / ((9 + 3) * -11))) + 17) + 5 = ((10 * (6 / (12 * -11))) + 17) + 5 = ((10 * (6 / -132)) + 17) + 5 = ((10 * 0) + 17) + 5 = (0 + 17) + 5 = 17 + 5 = 22 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 class Solution { public int evalRPN(String[] tokens) { int[] stack = new int[tokens....

<span title='2021-02-22 00:00:00 +0000 UTC'>February 22, 2021</span>&nbsp;·&nbsp;2 min&nbsp;·&nbsp;volyx

1598. Crawler Log Folder

![https://leetcode.com/problems/crawler-log-folder/] The Leetcode file system keeps a log each time some user performs a change folder operation. The operations are described below: “../” : Move to the parent folder of the current folder. (If you are already in the main folder, remain in the same folder). “./” : Remain in the same folder. “x/” : Move to the child folder named x (This folder is guaranteed to always exist). You are given a list of strings logs where logs[i] is the operation performed by the user at the ith step....

<span title='2021-02-22 00:00:00 +0000 UTC'>February 22, 2021</span>&nbsp;·&nbsp;4 min&nbsp;·&nbsp;volyx

1598. Crawler Log Folder

![https://leetcode.com/problems/crawler-log-folder/] The Leetcode file system keeps a log each time some user performs a change folder operation. The operations are described below: “../” : Move to the parent folder of the current folder. (If you are already in the main folder, remain in the same folder). “./” : Remain in the same folder. “x/” : Move to the child folder named x (This folder is guaranteed to always exist). You are given a list of strings logs where logs[i] is the operation performed by the user at the ith step....

<span title='2021-02-22 00:00:00 +0000 UTC'>February 22, 2021</span>&nbsp;·&nbsp;4 min&nbsp;·&nbsp;volyx

1021. Remove Outermost Parentheses

![https://leetcode.com/problems/remove-outermost-parentheses/] A valid parentheses string is either empty (""), “(” + A + “)”, or A + B, where A and B are valid parentheses strings, and + represents string concatenation. For example, “”, “()”, “(())()”, and “(()(()))” are all valid parentheses strings. A valid parentheses string S is primitive if it is nonempty, and there does not exist a way to split it into S = A+B, with A and B nonempty valid parentheses strings....

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

1047. Remove All Adjacent Duplicates In String

Given a string S of lowercase letters, a duplicate removal consists of choosing two adjacent and equal letters, and removing them. We repeatedly make duplicate removals on S until we no longer can. Return the final string after all such duplicate removals have been made. It is guaranteed the answer is unique. 1 2 3 4 5 6 Example 1: Input: "abbaca" Output: "ca" Explanation: For example, in "abbaca" we could remove "bb" since the letters are adjacent and equal, and this is the only possible move....

<span title='2021-02-20 00:00:00 +0000 UTC'>February 20, 2021</span>&nbsp;·&nbsp;2 min&nbsp;·&nbsp;volyx

1209. Remove All Adjacent Duplicates in String II

![https://leetcode.com/problems/remove-all-adjacent-duplicates-in-string-ii/] Given a string s, a k duplicate removal consists of choosing k adjacent and equal letters from s and removing them causing the left and the right side of the deleted substring to concatenate together. We repeatedly make k duplicate removals on s until we no longer can. Return the final string after all such duplicate removals have been made. It is guaranteed that the answer is unique. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 Example 1: Input: s = "abcd", k = 2 Output: "abcd" Explanation: There's nothing to delete....

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

155. Min Stack

![https://leetcode.com/problems/min-stack/] Design a stack that supports push, pop, top, and retrieving the minimum element in constant time. push(x) – Push element x onto stack. pop() – Removes the element on top of the stack. top() – Get the top element. getMin() – Retrieve the minimum element in the stack. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 Example 1: Input ["MinStack","push","push","push","getMin","pop","top","getMin"] [[],[-2],[0],[-3],[],[],[],[]] Output [null,null,null,null,-3,null,0,-2] Explanation MinStack minStack = new MinStack(); minStack....

<span title='2021-02-20 00:00:00 +0000 UTC'>February 20, 2021</span>&nbsp;·&nbsp;2 min&nbsp;·&nbsp;volyx