LeetCode - 150 - Minimum Interval to Include Each Query
The problem You are given a 2D integer array intervals, where intervals[i] = [lefti, righti] describes the ith interval starting at lefti and ending at righti (inclusive). The size of an interval is defined as the number of integers it contains, or more formally righti - lefti + 1. You are also given an integer array queries. The answer to the jth query is the size of the smallest interval i such that lefti <= queries[j] <= righti. If no such interval exists, the answer is -1. ...
LeetCode - 150 - Valid Parenthesis String
The problem Given a string s containing only three types of characters: '(', ')', and '*', return true if s is valid. The following rules define a valid string: Any left parenthesis '(' must have a corresponding right parenthesis ')'. Any right parenthesis ')' must have a corresponding left parenthesis '('. A left parenthesis '(' must go before the corresponding right parenthesis ')'. '*' could be treated as a single right parenthesis ')', a single left parenthesis '(', or an empty string "". Example 1: ...
LeetCode - 150 - Partition Labels
LeetCode - 150 - Partition Labels The problem You are given a string s. We want to partition the string into as many parts as possible so that each letter appears in at most one part. For example, the string "ababcc" can be partitioned into ["abab", "cc"], but partitions such as ["aba", "bcc"] or ["ab", "ab", "cc"] are invalid. Note that the partition is done so that after concatenating all the parts in order, the resultant string should be s. ...
LeetCode - 150 - Merge Triplets to Form Target Triplet
The problem A triplet is an array of three integers. You are given a 2D integer array triplets, where triplets[i] = [ai, bi, ci] describes the i-th 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): Choose two indices (0-indexed) i and j (i != j) and update triplets[j] to become [max(ai, aj), max(bi, bj), max(ci, cj)]. ...
LeetCode - 150 - Hand of Straights
The problem Alice has some number of cards, and she wants to rearrange the cards into groups so that each group is of size groupSize and consists of groupSize consecutive cards. Given an integer array hand, where hand[i] is the value written on the ith card, and an integer groupSize, return true if she can rearrange the cards, or false otherwise. Example 1: Input: hand = [1,2,3,6,2,3,4,7,8], groupSize = 3 Output: true Explanation: Alice's hand can be rearranged as [1,2,3], [2,3,4], [6,7,8] Example 2: ...