LeetCode 856 | Score of Parentheses | Java | Stack
AYER VERSE
0:00 / 0:00
LeetCode 856 | Score of Parentheses | Java | Stack
2 просмотра · 8 дней назад
AYER VERSE
24 подписчика
2 просмотра · 8 дней назад
In this video, I solve LeetCode 856 — Score of Parentheses using a Stack in Java.
Problem: https://leetcode.com/problems/score-o...
Approach:
• Use a stack to store scores of each nesting level
• () contributes 1
• (A) contributes 2 × A
• Adjacent scores are added
Time Complexity: O(n)
Space Complexity: O(n)