Dsa
Stack
Hard
Balanced Log Entries
You are given a list of log entries that represent nested events in a web application. Each log entry starts with an opening tag ('START') and ends with a closing tag ('END'). You need to determine if the log entries are balanced. A log is balanced if every 'START' has a corresponding 'END' in the correct order. Write a program that reads the log entries and prints 'BALANCED' if the log is balanced and 'UNBALANCED' otherwise.
Input format:
- A single line containing space-separated log entries (e.g., 'START START END END').
Output format:
- A single line containing either 'BALANCED' or 'UNBALANCED'.
Example:
Input:
START START END END
Output:
BALANCED
Key concepts
stackvalidationparsing
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now