Solved! Leetcode 2073. Time Needed to Buy Tickets

Table of ContentsDescription: Time Needed to Buy TicketsExample 1Example 2ConstraintsSolution 1Time Complexity Space ComplexitySolution 2Time ComplexitySpace Complexity Description: Time Needed to Buy Tickets There are n people in a line queuing to buy tickets, where the 0th person is at the front of the line and the (n - 1)th person is at the back of the line. You are given a 0-indexed integer array tickets of length n where the ...

Solved! Leetcode 1700. Number of Students Unable to Eat Lunch

Table of ContentsDescription Number of Students Unable to Eat LunchExample 1Example 2ConstraintsSolutionTime ComplexitySpace Complexity Description Number of Students Unable to Eat Lunch The school cafeteria offers circular and square sandwiches at lunch break, referred to by numbers 0 and 1 respectively. All students stand in a queue. Each student either prefers square or circular sandwiches. The number of sandwiches ...

Solved! Leetcode 950. Reveal Cards In Increasing Order

Table of ContentsDescription Reveal Cards In Increasing OrderExample 1Example 2ConstraintsSolutionTime ComplexitySpace Complexity Description Reveal Cards In Increasing Order You are given an integer array deck. There is a deck of cards where every card has a unique integer. The integer on the ith card is deck[i]. You can order the deck in any order you want. Initially, all the ...

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 1351. Count Negative Numbers in a Sorted Matrix

source: https://leetcode.com/problems/count-negative-numbers-in-a-sorted-matrix/description/ Count Negative Numbers in a Sorted Matrix Table of ContentsCount Negative Numbers in a Sorted MatrixDescriptionExample 1:Example 2:Constraints:SolutionFollow up Description Given a m x n matrix grid which is sorted in non-increasing order both row-wise and column-wise, return the number of negative numbers in grid. Example 1: Input: grid = [[4,3,2,-1],[3,2,1,-1],[1,1,-1,-2],[-1,-1,-2,-3]]Output: 8Explanation: There ...

Solved! Leetcode 1431. Kids With the Greatest Number of Candies

source: https://leetcode.com/problems/kids-with-the-greatest-number-of-candies/description/ Kids With the Greatest Number of Candies There are n kids with candies. You are given an integer array candies, where each candies[i] represents the number of candies the ith kid has, and an integer extraCandies, denoting the number of extra candies that you have. Return a boolean array result of length n, ...

Solved Leetcode 245. Shortest Word Distance III

source: https://leetcode.com/problems/shortest-word-distance-iii/description/ Shortest Word Distance III Given an array of strings wordsDict and two strings that already exist in the array word1 and word2, return the shortest distance between the occurrence of these two words in the list. Note that word1 and word2 may be the same. It is guaranteed that they represent two individual ...

Solved! Leetcode 2348. Number of Zero-Filled Subarrays

source: https://leetcode.com/problems/number-of-zero-filled-subarrays/description/ Number of Zero-Filled Subarrays Given an integer array nums, return the number of zero-filled subarrays. A subarray is a contiguous non-empty sequence of elements within an array. Example 1: Input: nums = [1,3,0,0,2,0,0,4] Output: 6 Explanation: There are 4 occurrences of [0] as a subarray. There are 2 occurrences of [0,0] as a ...

Solved! Leetcode 2187. Minimum Time to Complete Trips

Table of ContentsProblem StatementJavaPython Problem Statement source: https://leetcode.com/problems/minimum-time-to-complete-trips/description/ You are given an array time where time[i] denotes the time taken by the ith bus to complete one trip. Each bus can make multiple trips successively; that is, the next trip can start immediately after completing the current trip. Also, each bus operates independently; that is, ...

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 ...