Solved! Leetcode 646. Maximum Length of Pair Chain

source: https://leetcode.com/problems/maximum-length-of-pair-chain/description/ Maximum Length of Pair Chain You are given an array of n pairs pairs where pairs[i] = [lefti, righti] and lefti < righti. A pair p2 = [c, d] follows a pair p1 = [a, b] if b < c. A chain of pairs can be formed in this fashion. Return the length ...

Solved! 875. Koko Eating Bananas

Table of ContentsProblem Description : Koko Eating BananasExamplesConstraintsPython Problem Description : Koko Eating Bananas source: https://leetcode.com/problems/koko-eating-bananas/  Koko loves to eat bananas. There are n piles of bananas, the ith pile has piles[i] bananas. The guards have gone and will come back in h hours. Koko can decide her bananas-per-hour eating speed of k. Each hour, she chooses some pile of bananas and eats k bananas from ...

Solved! Leetcode 1345. Jump Game IV

source: https://leetcode.com/problems/jump-game-iv/description/ Jump Game IV Given an array of integers arr, you are initially positioned at the first index of the array. In one step you can jump from index i to index: i + 1 where: i + 1 < arr.length. i – 1 where: i – 1 >= 0. j where: arr[i] == ...

Solved! Leetcode 742. Nearest Leaf in a Binary Tree

source: https://leetcode.com/problems/closest-leaf-in-a-binary-tree/description/ Given the root of a binary tree where every node has a unique value and a target integer k, return the value of the nearest leaf node to the target k in the tree. Nearest to a leaf means the least number of edges traveled on the binary tree to reach any leaf ...

Solved! Leetcode 1586. Binary Search Tree Iterator II

source: https://leetcode.com/problems/binary-search-tree-iterator-ii/description/ Binary Search Tree Iterator II Implement the BSTIterator class that represents an iterator over the in-order traversal of a binary search tree (BST): BSTIterator(TreeNode root) Initializes an object of the BSTIterator class. The root of the BST is given as part of the constructor. The pointer should be initialized to a non-existent number ...

Solved! Leetcode 320. Generalized Abbreviation

source: https://leetcode.com/problems/generalized-abbreviation/description/ Generalized Abbreviation A word’s generalized abbreviation can be constructed by taking any number of non-overlapping and non-adjacent substrings and replacing them with their respective lengths. For example, "abcde" can be abbreviated into: "a3e" ("bcd" turned into "3") "1bcd1" ("a" and "e" both turned into "1") "5" ("abcde" turned into "5") "abcde" (no substrings ...

Solved! Leetcode 638. Shopping Offers

source: https://leetcode.com/problems/shopping-offers/description/ Shopping Offers In LeetCode Store, there are n items to sell. Each item has a price. However, there are some special offers, and a special offer consists of one or more different kinds of items with a sale price. You are given an integer array price where price[i] is the price of the ...

Solved Leetcode 474. Ones and Zeroes

source: https://leetcode.com/problems/ones-and-zeroes/description/ Ones and Zeroes You are given an array of binary strings strs and two integers m and n. Return the size of the largest subset of strs such that there are at most m 0’s and n 1’s in the subset. A set x is a subset of a set y if all ...

Solved! Leetcode 1255. Maximum Score Words Formed by Letters

source: https://leetcode.com/problems/maximum-score-words-formed-by-letters/description/ Maximum Score Words Formed by Letters Given a list of words, list of single letters (might be repeating) and score of every character. Return the maximum score of any valid set of words formed by using the given letters (words[i] cannot be used two or more times). It is not necessary to use ...

Solved! Leetcode 1129: Shortest Path with Alternating Colors

source: https://leetcode.com/problems/shortest-path-with-alternating-colors/ You are given an integer n, the number of nodes in a directed graph where the nodes are labeled from 0 to n – 1. Each edge is red or blue in this graph, and there could be self-edges and parallel edges. You are given two arrays redEdges and blueEdges where: redEdges[i] = ...