и посмотреть медиа
C# LeetCode - задачи
и посмотреть медиа
LeetCode C#.
AI bot for text-to-speech and voice cloning in Telegram. Create audio using neural network quickly and easily.
Задачи LeetCode на C#.
Задача: 665. Non-decreasing Array Сложность: medium Дан массив nums из n целых чисел. Ваша задача - проверить, можно ли сделать его неубывающим, изменив не более одного элемента. Мы определяем массив как неубывающий, если для каждого i (индексация с 0), такого что 0 nums[i + 2], то возвращаем false. 3⃣Возврат результата: Если количество изменений не превышает 1, вернуть true. 😎 Решение: public class Solution { public bool CheckPossibility(int[] nums) { int count = 0; for (int i = 1; i < nums.Length; i++) { if (nums[i] < nums[i - 1]) { if (count > 0) { return false; } count++; if (i == 1 || nums[i] >= nums[i - 2]) { nums[i - 1] = nums[i]; } else { nums[i] = nums[i - 1]; } } } return true; } } Ставь 👍 и забирай 📚 Базу знаний
Открыть канал и посмотреть медиаOnly registered users can share their opinion.
Be the first to share your impression of this resource!
Conductor inIT: inside, analytics, industry trends and career vacancies.
Motorcycles from Japan are available and on order. More than 250 units of equipment.