1213. Intersection of Three Sorted Arrays

1213. Intersection of Three Sorted Arrays Given three integer arrays arr1, arr2 and arr3 sorted in strictly increasing order, return a sorted array of only the integers that appeared in all three arrays. 1 2 3 4 5 6 7 8 9 10 Example 1: Input: arr1 = [1,2,3,4,5], arr2 = [1,2,5,7,9], arr3 = [1,3,4,5,8] Output: [1,5] Explanation: Only 1 and 5 appeared in the three arrays. Example 2: Input: arr1 = [197,418,523,876,1356], arr2 = [501,880,1593,1710,1870], arr3 = [521,682,1337,1395,1764] Output: [] Constraints:...

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

496. Next Greater Element I

496. Next Greater Element I The next greater element of some element x in an array is the first greater element that is to the right of x in the same array. You are given two distinct 0-indexed integer arrays nums1 and nums2, where nums1 is a subset of nums2. For each 0 <= i < nums1.length, find the index j such that nums1[i] == nums2[j] and determine the next greater element of nums2[j] in nums2....

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

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

1235. Maximum Profit in Job Scheduling

1235. Maximum Profit in Job Scheduling We have n jobs, where every job is scheduled to be done from startTime[i] to endTime[i], obtaining a profit of profit[i]. You’re given the startTime, endTime and profit arrays, return the maximum profit you can take such that there are no two jobs in the subset with overlapping time range. If you choose a job that ends at time X you will be able to start another job that starts at time X....

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

51. N-Queens

51. N-Queens The n-queens puzzle is the problem of placing n queens on an n x n chessboard such that no two queens attack each other. Given an integer n, return all distinct solutions to the n-queens puzzle. You may return the answer in any order. Each solution contains a distinct board configuration of the n-queens’ placement, where ‘Q’ and ‘.’ both indicate a queen and an empty space, respectively....

<span title='2021-07-06 00:00:00 +0000 UTC'>July 6, 2021</span>&nbsp;·&nbsp;3 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

13. Roman to Integer

13. Roman to Integer 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;4 min&nbsp;·&nbsp;volyx

1175. Prime Arrangements

1175. Prime Arrangements Return the number of permutations of 1 to n so that prime numbers are at prime indices (1-indexed.) (Recall that an integer is prime if and only if it is greater than 1, and cannot be written as a product of two positive integers both smaller than it.) Since the answer may be large, return the answer modulo 10^9 + 7. 1 2 3 4 5 6 7 8 9 10 Example 1: Input: n = 5 Output: 12 Explanation: For example [1,2,5,4,3] is a valid permutation, but [5,2,3,4,1] is not because the prime number 5 is at index 1....

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