Logo
TGCATALOG
Catalog Collections Blog
C# LeetCode - tasks

C# LeetCode - tasks

LeetCode C#.

No ratings
622
31.10.2026
622
31.10.2026
No ratings
622
31.10.2026
Safe redirect via bot
О канале

LeetCode C#.

Подписчиков 3,158
Тематика Technology
Язык English
Ссылка t.me/easy_c_sharp_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 tasks in C#.

Latest posts

C# LeetCode - tasks
C# LeetCode - tasks
🔒Открыть пост
и посмотреть медиа
Задача: 948. Bag of Tokens Сложность: medium Вы начинаете с начальной силой, равной power, начальным счетом 0 и мешком жетонов, представленным в виде целочисленного массива tokens, где каждый tokens[i] обозначает значение tokeni. Ваша цель - максимизировать общее количество очков, стратегически разыгрывая эти жетоны. За один ход вы можете разыграть неразыгранный жетон одним из двух способов (но не обоими для одного и того же жетона): лицом вверх: Если ваша текущая сила не меньше жетонов[i], вы можете сыграть токени, потеряв силу жетонов[i] и получив 1 очко. Лицом вниз: Если ваш текущий счет не меньше 1, вы можете сыграть токени, получив силу токенов[i] и потеряв 1 счет. Верните максимально возможный счет, который вы можете получить, сыграв любое количество токенов. Пример: Input: tokens = [100], power = 50 Output: 0 👨💻 Алгоритм: 1⃣Отсортировать массив tokens. Использовать два указателя: left и right, чтобы отслеживать начало и конец массива токенов. Инициализировать переменные для текущей силы power, текущего счета score и максимального счета maxScore 2⃣Повторять следующие шаги, пока left не превысит right: Если текущая сила power достаточна для разыгрывания токена tokens[left] лицом вверх, разыграть его и увеличить счет. Если текущая сила недостаточна, но счет больше 0, разыграть токен tokens[right] лицом вниз и уменьшить счет. Обновить максимальный счет, если текущий счет больше максимального. 3⃣Вернуть максимальный счет. 😎 Решение: public class Solution { public int BagOfTokensScore(int[] tokens, int power) { Array.Sort(tokens); int left = 0, right = tokens.Length - 1; int score = 0, maxScore = 0; while (left = tokens[left]) { power -= tokens[left]; score++; left++; maxScore = Math.Max(maxScore, score); } else if (score > 0) { power += tokens[right]; score--; right--; } else { break; } } return maxScore; } } Ставь 👍 и забирай 📚 Базу знаний
C# LeetCode - tasks
FAQ

Open C# LeetCode - tasks 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 C# LeetCode - tasks directly in Telegram unless the resource description says otherwise.

Access depends on the resource. Check the current information in Telegram after opening C# LeetCode - tasks.

The exact features depend on the resource. Open C# LeetCode - tasks to see its current functions, content and access conditions.
Subscriber dynamics
+-1.0% last 30 days
Current
3,158
Month ago
3,190
Average growth
+-1 / day
Updated
5 hours ago

Reviews for channel C# LeetCode - tasks

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