Tümü Yeni

user:thomas kullanıcı tarafından oluşturulan gistler

title:mygist belirtilen isme sahip gistler

filename:myfile.txt belirtilen isimde dosyaları olan gistler

extension:yml belirtilen uzantıya sahip dosyalara sahip gistler

language:go belirtilen dilde dosyaları olan gistler

topic:homelab gists with given topic

Kaydol

Giriş


Tümü Yeni Kaydol Giriş

All gists matching topic interview

Yakın zamanda oluşturuldu
En eski oluşturuldu
Yakın zamanda güncellendi
En eski güncellendi

linkjobai / Monotonic Stack: The Pattern Behind "Next Greater Element" Questions

0 beğeniler
0 çatallar
1 dosyalar
Son aktivite 1794541558
Interview prep notes
interview

Monotonic Stack: The Pattern Behind "Next Greater Element" Questions

If a question asks for the next greater, previous smaller, or "how many days until a warmer temperature", a monotonic stack usually turns an O(n²) scan into O(n).

Core idea

Keep a stack of indices whose values are in sorted order (decreasing for "next greater"). When a new value breaks the order, it is the answer for every index you pop.

def daily_temperatures(temps):          # LeetCode 739
Daha yeni Daha eski

Opengist tarafından desteklenmektedir ⋅ Load: 25ms⋅

Türkçe
Čeština Deutsch English Español Français Magyar Italiano 日本語 Polski Português Русский Türkçe Українська 中文 繁體中文