и посмотреть медиа
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.
Задача: 423. Reconstruct Original Digits from English Сложность: medium Дана строка s, содержащая неупорядоченное английское представление цифр от 0 до 9, верните цифры в порядке возрастания. Пример: Input: s = "owoztneoer" Output: "012" 👨💻 Алгоритм: 1⃣Подсчитайте количество каждого символа в строке s с помощью хэш-таблицы или массива, чтобы определить количество каждого символа. 2⃣Используйте уникальные символы, присутствующие только в одном числе (например, 'z' для 0, 'w' для 2, 'u' для 4, 'x' для 6, 'g' для 8), чтобы определить количество этих цифр в строке. Затем определите количество остальных цифр, вычитая уже найденные цифры. 3⃣Соберите найденные цифры в строку в порядке возрастания и верните результат. 😎 Решение: class Solution { originalDigits(s) { const count = new Array(26).fill(0); for (const letter of s) { count[letter.charCodeAt(0) - 97]++; } const out = new Array(10).fill(0); out[0] = count[25]; out[2] = count[22]; out[4] = count[20]; out[6] = count[23]; out[8] = count[6]; out[3] = count[7] - out[8]; out[5] = count[5] - out[4]; out[7] = count[18] - out[6]; out[9] = count[8] - out[5] - out[6] - out[8]; out[1] = count[13] - out[7] - 2 * out[9]; const output = []; for (let i = 0; i < 10; i++) { for (let j = 0; j < out[i]; j++) { output.push(i); } } return output.join(''); } } Ставь 👍 и забирай 📚 Базу знаний
Открыть канал и посмотреть медиаOnly registered users can share their opinion.
Be the first to share your impression of this resource!