Logo
TGCATALOG
Catalog Collections Blog
Java | LeetCode

Java | LeetCode

LeetCode tasks and solutions in Java.

No ratings
283
30.11.2026
283
30.11.2026
No ratings
283
30.11.2026
Safe redirect via bot
О канале

LeetCode tasks and solutions in Java.

Подписчиков —
Тематика Technology
Ссылка @easy_java_task

We also recommend

Kekaton AI | Voiceover and voice clone
Kekaton AI | Voiceover and voice clone
Bot

AI bot for text-to-speech and voice cloning in Telegram. Create audio using neural network quickly and easily.

Description

LeetCode task solutions in Java with emphasis on clean code and optimization. Topics: arrays, trees, graphs, dynamic programming. Ideal for technical preparation.

Latest posts

Java | LeetCode
Java | LeetCode
🔒Открыть пост
и посмотреть медиа
Задача: 856. Score of Parentheses Сложность: medium Дана строка s, состоящая из сбалансированных скобок, верните счёт строки. Счёт сбалансированной строки скобок основывается на следующих правилах: "()" имеет счёт 1. AB имеет счёт A + B, где A и B — сбалансированные строки скобок. (A) имеет счёт 2 * A, где A — сбалансированная строка скобок. Пример: Input: s = "()" Output: 1 👨💻 Алгоритм: 1⃣Назовём сбалансированную строку примитивной, если её нельзя разделить на две непустые сбалансированные строки. 2⃣Отслеживая баланс (количество открывающих скобок минус количество закрывающих скобок), мы можем разделить строку S на примитивные подстроки S = P_1 + P_2 + ... + P_n. Тогда, по определению, score(S) = score(P_1) + score(P_2) + ... + score(P_n). 3⃣Для каждой примитивной подстроки (S[i], S[i+1], ..., S[k]), если длина строки равна 2, то её счёт равен 1. В противном случае, счёт равен удвоенному счёту подстроки (S[i+1], S[i+2], ..., S[k-1]). 😎 Решение: class Solution { public int scoreOfParentheses(String S) { return F(S, 0, S.length()); } public int F(String S, int i, int j) { int ans = 0, bal = 0; for (int k = i; k < j; ++k) { bal += S.charAt(k) == '(' ? 1 : -1; if (bal == 0) { if (k - i == 1) ans++; else ans += 2 * F(S, i + 1, k); i = k + 1; } } return ans; } } Ставь 👍 и забирай 📚 Базу знаний
Java | LeetCode
FAQ

Open Java | LeetCode in Telegram and press the Start button. No separate registration is required.

Yes. The service is designed to be straightforward: open the resource, follow the on-screen instructions and start using it.

No. You can use Java | LeetCode directly in Telegram unless the resource description says otherwise.

Access depends on the resource. Check the current information in Telegram after opening Java | LeetCode.

The exact features depend on the resource. Open Java | LeetCode to see its current functions, content and access conditions.

Reviews for channel Java | LeetCode

Log in to leave a review

Only registered users can share their opinion.

No reviews yet

Be the first to share your impression of this resource!

Similar resources

Loading
Switch to Light Theme
Home Catalog Collections Blog Login