## Solved! Leetcode 1626: Best Team With No Conflicts

Table of ContentsBest Team: Problem StatementJavaPython Best Team: Problem Statement You are the manager of a basketball team and your task is to form a best team. For the upcoming tournament, you want to choose the team with the highest overall score. The score of the team is the sum of scores of all the ...

## Solved! Leetcode 491: Non-decreasing Subsequences

https://leetcode.com/problems/non-decreasing-subsequences/description/ Given an integer array nums, return all the different possible non-decreasing subsequences of the given array with at least two elements. You may return the answer in any order. Example 1: Input: nums = [4,6,7,7] Output: [[4,6],[4,6,7],[4,6,7,7],[4,7],[4,7,7],[6,7],[6,7,7],[7,7]] class Solution { public List<List<Integer>> findSubsequences(int[] nums) { Set<List<Integer>> res = new HashSet<>(); helper(nums, 0, new ArrayList<>(), res); return new ...

## Solved! Leetcode 1533: Find the Index of the Large Integer

https://leetcode.com/problems/find-the-index-of-the-large-integer/description/ We have an integer array arr, where all the integers in arr are equal except for one integer, which is larger than the rest of the integers. You will not be given direct access to the array. Instead, you will have an API ArrayReader which have the following functions: int compareSub(int l, int r, int x, int y): where 0 <= l, r, ...

## Leetcode 57: Insert Interval

https://leetcode.com/problems/insert-interval/description/ You are given an array of non-overlapping intervals intervals where intervals[i] = [starti, endi] represent the start and the end of the ith interval and intervals is sorted in ascending order by starti. You are also given an interval newInterval = [start, end] that represents the start and end of another interval. Insert newInterval into intervals such that intervals is still sorted in ascending order by starti and intervals still does not have any overlapping ...

## Leetcode 1061: Lexicographically Smallest Equivalent String

https://leetcode.com/problems/lexicographically-smallest-equivalent-string/description/ You are given two strings of the same length s1 and s2 and a string baseStr. We say s1[i] and s2[i] are equivalent characters. For example, if s1 = "abc" and s2 = "cde", then we have 'a' == 'c', 'b' == 'd', and 'c' == 'e'. Equivalent characters follow the usual rules of any equivalence relation: Reflexivity: 'a' == 'a'.Symmetry: 'a' == 'b' implies 'b' == 'a'.Transitivity: 'a' == 'b' and 'b' == 'c' implies 'a' == ...

## Leetcode 1519: Number of Nodes in the Sub-Tree With the Same Label

You are given a tree (i.e., a connected, undirected graph that has no cycles) consisting of n nodes numbered from 0 to n - 1 and exactly n - 1 edges. The root of the tree is the node 0, and each node of the tree has a label which is a lower-case character given in the string labels (i.e., The node with the number i has the label labels[i]). The edges array is given ...

## Leetcode 1443: Minimum Time to Collect All Apples in a Tree

Given an undirected tree consisting of n vertices numbered from 0 to n-1, which has some apples in their vertices. You spend 1 second to walk over one edge of the tree. Return the minimum time in seconds you have to spend to collect all apples in the tree, starting at vertex 0 and coming back to this vertex. The edges of the ...

## Leetcode 2214: Minimum Health to Beat Game

You are playing a game that has n levels numbered from 0 to n - 1. You are given a 0-indexed integer array damage where damage[i] is the amount of health you will lose to complete the ith level. You are also given an integer armor. You may use your armor ability at most once during the game on any level, which will protect you from at most armor damage. You must complete the levels in ...

## Solved! Leetcode 100: Same Tree

Table of ContentsJava SolutionPython Solution Given the roots of two binary trees p and q, write a function to check if they are the same or not. Two binary trees are considered to be same trees if they are structurally identical and the nodes have the same value. Example 1. Input: p = [1,2,3], q = [1,2,3]Output: trueExample ...

## Leetcode 452: Minimum Number of Arrows to Burst Balloons

There are some spherical balloons taped onto a flat wall that represents the XY-plane. The balloons are represented as a 2D integer array points where points[i] = [xstart, xend] denotes a balloon whose horizontal diameter stretches between xstart and xend. You do not know the exact y-coordinates of the balloons. Arrows can be shot up directly vertically (in the positive y-direction) from different points along the ...