Lesson 14 of 24

set, stack, queue, priority_queueset, stack, queue and priority_queue

11 min 35 XP

set: தனித்துவமான, வரிசைப்படுத்தப்பட்ட மதிப்புகள். stack: கடைசியாக வந்தது முதலில் வெளியே (LIFO). queue: முதலில் வந்தது முதலில் (FIFO). priority_queue: எப்போதும் பெரியது மேலே.

set holds unique sorted values. stack is last-in-first-out (LIFO), queue is first-in-first-out (FIFO), and priority_queue always keeps the largest on top.

Example: edit me and press Run

Output Loading C++ (first time takes a few seconds)
Press Run to see the result here.

Balanced brackets சோதனை stack-ன் மிகப் பிரபலமான interview கேள்வி: திறக்கும் bracket-ஐ push, மூடும் bracket வந்தால் top பொருந்துகிறதா என்று பார்த்து pop.

Balanced brackets is the classic stack interview question: push opening brackets; on a closing bracket, check the top matches and pop.

Challenge

+35 XP

Brackets மட்டும் உள்ள ஒரு string-ஐப் படித்து ((), [], {}), அவை சரியாக மூடப்பட்டிருந்தால் "Balanced", இல்லையெனில் "Not balanced" என்று print செய்யுங்கள். Input: {[()]} → Output: Balanced

Read a string of brackets ((), [], {}). Print "Balanced" if every bracket is closed in the right order, otherwise "Not balanced". Input: {[()]} → Output: Balanced

Output Loading C++ (first time takes a few seconds)
Press Run to see the result here.