503. Next Greater Element II

503. Next Greater Element II Given a circular integer array nums (i.e., the next element of nums[nums.length - 1] is nums[0]), return the next greater number for every element in nums. The next greater number of a number x is the first greater number to its traversing-order next in the array, which means you could search circularly to find its next greater number. If it doesn’t exist, return -1 for this number....

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

1329. Sort the Matrix Diagonally

1329. Sort the Matrix Diagonally A matrix diagonal is a diagonal line of cells starting from some cell in either the topmost row or leftmost column and going in the bottom-right direction until reaching the matrix’s end. For example, the matrix diagonal starting from mat[2][0], where mat is a 6 x 3 matrix, includes cells mat[2][0], mat[3][1], and mat[4][2]. Given an m x n matrix mat of integers, sort each matrix diagonal in ascending order and return the resulting matrix....

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

1348. Tweet Counts Per Frequency

1348. Tweet Counts Per Frequency A social media company is trying to monitor activity on their site by analyzing the number of tweets that occur in select periods of time. These periods can be partitioned into smaller time chunks based on a certain frequency (every minute, hour, or day). For example, the period [10, 10000] (in seconds) would be partitioned into the following time chunks with these frequencies: Every minute (60-second chunks): [10,69], [70,129], [130,189], …, [9970,10000] Every hour (3600-second chunks): [10,3609], [3610,7209], [7210,10000] Every day (86400-second chunks): [10,10000] Notice that the last chunk may be shorter than the specified frequency’s chunk size and will always end with the end time of the period (10000 in the above example)....

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

1428. Leftmost Column with at Least a One

1428. Leftmost Column with at Least a One This problem is an interactive problem.) A row-sorted binary matrix means that all elements are 0 or 1 and each row of the matrix is sorted in non-decreasing order. Given a row-sorted binary matrix binaryMatrix, return the index (0-indexed) of the leftmost column with a 1 in it. If such an index does not exist, return -1. You can’t access the Binary Matrix directly....

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

162. Find Peak Element

162. Find Peak Element A peak element is an element that is strictly greater than its neighbors. Given an integer array nums, find a peak element, and return its index. If the array contains multiple peaks, return the index to any of the peaks. You may imagine that nums[-1] = nums[n] = -∞. You must write an algorithm that runs in O(log n) time. 1 2 3 4 5 6 7 8 9 10 11 Example 1: Input: nums = [1,2,3,1] Output: 2 Explanation: 3 is a peak element and your function should return the index number 2....

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

240. Search a 2D Matrix II

240. 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-07-06 00:00:00 +0000 UTC'>July 6, 2021</span>&nbsp;·&nbsp;1 min&nbsp;·&nbsp;volyx

74. Search a 2D Matrix

74. Search a 2D Matrix Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties: Integers in each row are sorted from left to right. The first integer of each row is greater than the last integer of the previous row. 1 2 3 4 Example 1: Input: matrix = [[1,3,5,7],[10,11,16,20],[23,30,34,60]], target = 3 Output: true 1 2 3 4 Example 2: Input: matrix = [[1,3,5,7],[10,11,16,20],[23,30,34,60]], target = 13 Output: false Constraints:...

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

Wine Selling Problem

Wine Selling Problem Problem statement: Given n wines in a row, with integers denoting the cost of each wine respectively. Each year you can sell the first or the last wine in the row. Let the initial profits from the wines be P1, P2, P3…Pn. In the Yth year, the profit from the ith wine will be Y*P[i]. The goal is to calculate the maximum profit that can be earned by selling all the wines....

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

12. Integer to Roman

12. Integer to Roman Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M. Symbol Value I 1 V 5 X 10 L 50 C 100 D 500 M 1000 For example, 2 is written as II in Roman numeral, just two one’s added together. 12 is written as XII, which is simply X + II. The number 27 is written as XXVII, which is XX + V + II....

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

50. Pow(x, n)

50. Pow(x, n) Implement pow(x, n), which calculates x raised to the power n (i.e., xn). 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Example 1: Input: x = 2.00000, n = 10 Output: 1024.00000 Example 2: Input: x = 2.10000, n = 3 Output: 9.26100 Example 3: Input: x = 2.00000, n = -2 Output: 0.25000 Explanation: 2-2 = 1/22 = 1/4 = 0....

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

1004. Max Consecutive Ones III

11004. Max Consecutive Ones III Given a binary array nums and an integer k, return the maximum number of consecutive 1’s in the array if you can flip at most k 0’s. 1 2 3 4 5 6 7 8 9 10 11 12 13 Example 1: Input: nums = [1,1,1,0,0,0,1,1,1,1,0], k = 2 Output: 6 Explanation: [1,1,1,0,0,1,1,1,1,1,1] Bolded numbers were flipped from 0 to 1. The longest subarray is underlined....

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

11. Container With Most Water

11. Container With Most Water Given n non-negative integers a1, a2, …, an , where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of the line i is at (i, ai) and (i, 0). Find two lines, which, together with the x-axis forms a container, such that the container contains the most water. Notice that you may not slant the container....

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

159. Longest Substring with At Most Two Distinct Characters

159. Longest Substring with At Most Two Distinct Characters Given a string s, return the length of the longest substring that contains at most two distinct characters. 1 2 3 4 5 6 7 8 9 10 11 Example 1: Input: s = "eceba" Output: 3 Explanation: The substring is "ece" which its length is 3. Example 2: Input: s = "ccaabbb" Output: 5 Explanation: The substring is "aabbb" which its length is 5....

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

209. Minimum Size Subarray Sum

209. Minimum Size Subarray Sum Given an array of positive integers nums and a positive integer target, return the minimal length of a contiguous subarray [numsl, numsl+1, …, numsr-1, numsr] of which the sum is greater than or equal to target. If there is no such subarray, return 0 instead. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Example 1: Input: target = 7, nums = [2,3,1,2,4,3] Output: 2 Explanation: The subarray [4,3] has the minimal length under the problem constraint....

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

3. Longest Substring Without Repeating Characters

3. Longest Substring Without Repeating Characters Given a string s, find the length of the longest substring without repeating characters. 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: s = "abcabcbb" Output: 3 Explanation: The answer is "abc", with the length of 3. Example 2: Input: s = "bbbbb" Output: 1 Explanation: The answer is "b", with the length of 1....

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