Solved! Leetcode 983. Minimum Cost For Tickets

source: https://leetcode.com/problems/minimum-cost-for-tickets/description/ Table of ContentsMinimum Cost For TicketsExample 1Example 2ConstraintsSolution Minimum Cost For Tickets You have planned some train traveling one year in advance. The days of the year you will travel are given as an integer array days. Each day is an integer from 1 to 365. Train tickets are sold in three different ...

Solved! Leetcode 1319. Number of Operations to Make Network Connected

source: https://leetcode.com/problems/number-of-operations-to-make-network-connected/description/ Table of ContentsNumber of Operations to Make Network ConnectedDescriptionExample 1:Example 2:Example 3:Constraints:Solution Number of Operations to Make Network Connected Description There are n computers numbered from 0 to n – 1 connected by ethernet cables connections forming a network where connections[i] = [ai, bi] represents a connection between computers ai and bi. Any ...

Solved! Leetcode 63. Unique Paths II

source: https://leetcode.com/problems/unique-paths-ii/ Unique Paths II Table of ContentsUnique Paths IIDescriptionExample 1:Example 2:Constraints:Solution Description You are given an m x n integer array grid. There is a robot initially located at the top-left corner (i.e., grid[0][0]). The robot tries to move to the bottom-right corner (i.e., grid[m – 1][n – 1]). The robot can only move ...

Solved! Leetcode 77. Combinations

source: https://leetcode.com/problems/combinations/description/ Combinations Table of ContentsCombinationsDescriptionExample 1:Example 2:Constraints:Solution Description Given two integers n and k, return all possible combinations of k numbers chosen from the range [1, n].You may return the answer in any order. Example 1: Input: n = 4, k = 2Output: [[1,2],[1,3],[1,4],[2,3],[2,4],[3,4]]Explanation: There are 4 choose 2 = 6 total combinations. Note ...

Solved! Leetcode 2616. Minimize the Maximum Difference of Pairs

source: https://leetcode.com/problems/minimize-the-maximum-difference-of-pairs/ Table of ContentsMinimize the Maximum Difference of PairsExample 1:Example 2:Constraints:Solution Minimize the Maximum Difference of Pairs You are given a 0-indexed integer array nums and an integer p. Find p pairs of indices of nums to minimize the maximum difference amongst all the pairs. Also, ensure no index appears more than once amongst ...

Solved! Leetcode 139. Word Break

source: https://leetcode.com/problems/word-break/ Table of ContentsWord BreakDescriptionExample 1:Example 2:Example 3:Constraints:Solution Word Break Description Given a string s and a dictionary of strings wordDict, return true if s can be segmented into a space-separated sequence of one or more dictionary words. Note that the same word in the dictionary may be reused multiple times in the segmentation. ...

Solved! Leetcode 920. Number of Music Playlists

source: https://leetcode.com/problems/number-of-music-playlists/ Table of ContentsNumber of Music PlaylistsDescriptionExample 1:Example 2:Example 3:Constraints:Solution Number of Music Playlists Description Your music player contains n different songs. You want to listen to goal songs (not necessarily different) during your trip. To avoid boredom, you will create a playlist so that: Every song is played at least once. A song ...

Solved! Leetcode 137. Single Number II

source: https://leetcode.com/problems/single-number-ii/description/ Table of ContentsSingle Number IIDescriptionExample 1:Example 2:Constraints:Solution Single Number II Description Given an integer array nums where every element appears three times except for one, which appears exactly once. Find the single element and return it. You must implement a solution with a linear runtime complexity and use only constant extra space. Example ...

Solved! Leetcode 1493. Longest Subarray of 1’s After Deleting One Element

source: https://leetcode.com/problems/longest-subarray-of-1s-after-deleting-one-element/description/ Table of ContentsLongest Subarray of 1’s After Deleting One ElementDescriptionExample 1:Example 2:Example 3:Constraints:Solution Longest Subarray of 1’s After Deleting One Element Description Given a binary array nums, you should delete one element from it. Return the size of the longest non-empty subarray containing only 1’s in the resulting array. Return 0 if there ...

Solved! Leetcode 1161. Maximum Level Sum of a Binary Tree

Solved! Leetcode 1161. Maximum Level Sum of a Binary Tree
source: https://leetcode.com/problems/maximum-level-sum-of-a-binary-tree/description/ Table of ContentsMaximum Level Sum of a Binary TreeExample 1:Example 2:Constraints:Solution Maximum Level Sum of a Binary Tree Given the root of a binary tree, the level of its root is 1, the level of its children is 2, and so on. Return the smallest level x such that the sum of all ...