Перейти к содержимому

🔥 **LeetCode 856 – Score of Parentheses | Java Solution**

Rupesh Sharma

0:00 / 0:00

🔥 **LeetCode 856 – Score of Parentheses | Java Solution**

9 просмотров · 2 недели назад
Rupesh Sharma
43 подписчика
9 просмотров · 2 недели назад
🔥 *LeetCode 856 – Score of Parentheses | Java Solution* In this video, we solve *LeetCode 856: Score of Parentheses* using a simple and efficient **Stack approach in Java**. 📌 *Problem:* Given a balanced parentheses string `s`, calculate its score based on these rules: • `()` → Score = 1 • `AB` → Score = A + B • `(A)` → Score = 2 × A 💡 *Examples:* `()` → `1` `(())` → `2` `()()` → `2` 🚀 *Approach Used:* We use a *Stack* to keep track of the scores at different levels of nested parentheses. When we encounter `()`, we add `1`. For nested parentheses, we multiply the inner score by `2`. ⏱️ *Time Complexity:* O(n) 💾 *Space Complexity:* O(n) This problem is a great way to understand **Stacks, Parentheses Problems, and Nested Expressions**, which are commonly asked in coding interviews. 👍 If you found this video helpful, *Like, Share & Subscribe* for more LeetCode and DSA solutions! #LeetCode #LeetCode856 #ScoreOfParentheses #Java #DSA #CodingInterview #Stack #Programming #LeetCodeJava #Coding