и посмотреть медиа
JavaScript | LeetCode
и посмотреть медиа
LeetCode tasks and solutions in JavaScript. Ideal for interview preparation and improving algorithm skills.
LeetCode tasks and solutions in JavaScript. Ideal for interview preparation and improving algorithm skills.
AI bot for text-to-speech and voice cloning in Telegram. Create audio using neural network quickly and easily.
The channel is dedicated to solving LeetCode tasks in JavaScript. It contains code examples for popular algorithmic problems frequently encountered in interviews. The materials will help master data structures, sorting, dynamic programming, and other key topics. Suitable for junior and middle developers looking to improve their skills.
Задача: №27. Remove Element Сложность: easy Дан массив nums и число val. Нужно удалить все вхождения val из массива, на месте, и вернуть количество оставшихся элементов. Элементы можно переставлять. Остаток массива не важен. Пример: Input: nums = [3,2,2,3], val = 3 Output: 2 👨💻 Алгоритм: 1️⃣ Вводим указатель k = 0, который отслеживает количество элементов, не равных val. 2️⃣ Проходим по каждому элементу x в массиве: - Если x !== val, присваиваем nums[k] = x и увеличиваем k 3️⃣ После прохода k будет равен количеству нужных элементов. Возвращаем k. 😎 Решение: var removeElement = function (nums, val) { let k = 0; for (const x of nums) { if (x !== val) { nums[k++] = x; } } return k; }; Ставь 👍 и забирай 📚 Базу знаний
Открыть канал и посмотреть медиаOnly registered users can share their opinion.
Be the first to share your impression of this resource!