Leetcode 2832. Maximal Range That Each Element Is Maximum in It

Posted on Tue 17 December 2024 in Leetcode Premium • Tagged with monotonic-stack

Question Link : https://leetcode.com/problems/maximal-range-that-each-element-is-maximum-in-it/

Difficulty: Medium

Premium: True

Question

You are given a 0-indexed array nums of distinct integers. Let us define a 0-indexed array ans of the same length as nums in the following way:

ans[i] is the maximum length of a subarray nums[l …


Continue reading

Leetcode 1673. Find the Most Competitive Subsequence

Posted on Fri 13 December 2024 in Leetcode • Tagged with monotonic-stack

Question Link : https://leetcode.com/problems/find-the-most-competitive-subsequence/

Difficulty: Medium

Premium: False

Question

Given an integer array nums and a positive integer k, return the most competitive subsequence of nums of size k. An array's subsequence is a resulting sequence obtained by erasing some (possibly zero) elements from the array. We …


Continue reading

Leetcode 0901. Online Stock Span

Posted on Tue 08 November 2022 in Leetcode • Tagged with monotonic-stack

Question Link : https://leetcode.com/problems/online-stock-span/

Difficulty: Medium

Question

Design an algorithm that collects daily price quotes for some stock and returns the span of that stock's price for the current day. The span of the stock's price today is defined as the maximum number of consecutive days (starting …


Continue reading

Leetcode 0665. Non-decreasing Array

Posted on Sat 25 June 2022 in Leetcode • Tagged with monotonic-stack

Question Link : https://leetcode.com/problems/non-decreasing-array/

Difficulty: Medium

Question

Given an array nums with n integers, your task is to check if it could become non-decreasing by modifying at most one element. We define an array is non-decreasing if nums[i] <= nums[i + 1] holds for every i (0-based …


Continue reading