1360. Number of Days Between Two Dates

1360. Number of Days Between Two Dates Write a program to count the number of days between two dates. The two dates are given as strings, their format is YYYY-MM-DD as shown in the examples. 1 2 3 4 5 6 7 8 9 Example 1: Input: date1 = "2019-06-29", date2 = "2019-06-30" Output: 1 Example 2: Input: date1 = "2020-01-15", date2 = "2019-12-31" Output: 15 Constraints: The given dates are valid dates between the years 1971 and 2100....

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

1528. Shuffle String

1528. Shuffle String A city’s skyline is the outer contour of the silhouette formed by all the buildings in that city when viewed from a distance. Given the locations and heights of all the buildings, return the skyline formed by these buildings collectively. The geometric information of each building is given in the array buildings where buildings[i] = [lefti, righti, heighti]: lefti is the x coordinate of the left edge of the ith building....

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

1266. Minimum Time Visiting All Points

1266. Minimum Time Visiting All Points On a 2D plane, there are n points with integer coordinates points[i] = [xi, yi]. Return the minimum time in seconds to visit all the points in the order given by points. You can move according to these rules: In 1 second, you can either: move vertically by one unit, move horizontally by one unit, or move diagonally sqrt(2) units (in other words, move one unit vertically then one unit horizontally in 1 second)....

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

270. Closest Binary Search Tree Value

270. Closest Binary Search Tree Value Given the root of a binary search tree and a target value, return the value in the BST that is closest to the target. 1 2 3 4 Example 1: Input: root = [4,2,5,1,3], target = 3.714286 Output: 4 1 2 3 4 Example 2: Input: root = [1], target = 4.428571 Output: 1 Constraints: The number of nodes in the tree is in the range [1, 104]....

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

252. Meeting Rooms

252. Meeting Rooms Given an array of meeting time intervals where intervals[i] = [starti, endi], determine if a person could attend all meetings. 1 2 3 4 5 6 7 8 9 Example 1: Input: intervals = [[0,30],[5,10],[15,20]] Output: false Example 2: Input: intervals = [[7,10],[2,4]] Output: true Constraints: 0 <= intervals.length <= 10^4 intervals[i].length == 2 0 <= starti < endi <= 10^6 Solution 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 class Solution { public boolean canAttendMeetings(int[][] intervals) { if (intervals....

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

253. Meeting Rooms II

253. Meeting Rooms II Given an array of meeting time intervals intervals where intervals[i] = [starti, endi], return the minimum number of conference rooms required. 1 2 3 4 5 6 7 8 9 Example 1: Input: intervals = [[0,30],[5,10],[15,20]] Output: 2 Example 2: Input: intervals = [[7,10],[2,4]] Output: 1 Constraints: 1 <= intervals.length <= 10^4 0 <= starti < endi <= 10^6 Solution 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 class Solution { /* [[0,30],[5,10],[15,20]] [ 0,30] [ 5,10] ---- [15,20] (1, 10), (2, 7), (3, 19), (8, 12), (10, 20), (11, 30) */ public int minMeetingRooms(int[][] intervals) { Arrays....

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

157. Read N Characters Given Read4

157. Read N Characters Given Read4 Given a file and assume that you can only read the file using a given method read4, implement a method to read n characters. Method read4: The API read4 reads four consecutive characters from file, then writes those characters into the buffer array buf4. The return value is the number of actual characters read. Note that read4() has its own file pointer, much like FILE *fp in C....

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

345. Reverse Vowels of a String

1482. Minimum Number of Days to Make m Bouquets Given a string s, reverse only all the vowels in the string and return it. The vowels are ‘a’, ’e’, ‘i’, ‘o’, and ‘u’, and they can appear in both cases. 1 2 3 4 5 6 7 8 9 Example 1: Input: s = "hello" Output: "holle" Example 2: Input: s = "leetcode" Output: "leotcede" Constraints: 1 <= s.length <= 3 * 105 s consist of printable ASCII characters....

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

977. Squares of a Sorted Array

977. Squares of a Sorted Array Given an integer array nums sorted in non-decreasing order, return an array of the squares of each number sorted in non-decreasing order. 1 2 3 4 5 6 7 8 9 10 11 Example 1: Input: nums = [-4,-1,0,3,10] Output: [0,1,9,16,100] Explanation: After squaring, the array becomes [16,1,0,9,100]. After sorting, it becomes [0,1,9,16,100]. Example 2: Input: nums = [-7,-3,2,3,11] Output: [4,9,9,49,121] Constraints: 1 <= nums....

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

21. Merge Two Sorted Lists

21. Merge Two Sorted Lists Merge two sorted linked lists and return it as a sorted list. The list should be made by splicing together the nodes of the first two lists. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 Example 1: Input: l1 = [1,2,4], l2 = [1,3,4] Output: [1,1,2,3,4,4] Example 2: Input: l1 = [], l2 = [] Output: [] Example 3: Input: l1 = [], l2 = [0] Output: [0] Constraints:...

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

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

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