и посмотреть медиа
JavaScript LeetCode
и посмотреть медиа
Tareas y soluciones de LeetCode en JavaScript. Ideal para la preparación de entrevistas y la mejora de habilidades de algoritmo.
Tareas y soluciones de LeetCode en JavaScript. Ideal para la preparación de entrevistas y la mejora de habilidades de algoritmo.
bot de IA para clonar texto a voz y voz en Telegram. Cree audio utilizando la red neuronal de forma rápida y fácil.
El canal está dedicado a resolver las tareas de LeetCode en JavaScript. Contiene ejemplos de códigos para problemas algoritmos populares que se encuentran frecuentemente en entrevistas. Los materiales ayudarán a dominar estructuras de datos, clasificación, programación dinámica y otros temas clave.
Задача: 567. Permutation in String Сложность: medium Даны две строки s1 и s2. Верните true, если s2 содержит перестановку s1, или false в противном случае. Другими словами, верните true, если одна из перестановок s1 является подстрокой s2. Пример: Input: s1 = "ab", s2 = "eidbaooo" Output: true Explanation: s2 contains one permutation of s1 ("ba"). 👨💻 Алгоритм: 1⃣Создать массив для подсчета символов в строке s1. Затем создать аналогичный массив для первых len(s1) символов строки s2. 2⃣Использовать скользящее окно для перемещения по строке s2. Для каждой позиции окна обновлять массив подсчета символов и сравнивать его с массивом для строки s1. 3⃣Если массивы совпадают на любом этапе, вернуть true. Если окно достигает конца строки s2 и совпадений не найдено, вернуть false. 😎 Решение: var checkInclusion = function(s1, s2) { let s1Len = s1.length, s2Len = s2.length; if (s1Len > s2Len) return false; let s1Count = new Array(26).fill(0); let s2Count = new Array(26).fill(0); for (let i = 0; i < s1Len; i++) { s1Count[s1.charCodeAt(i) - 97]++; s2Count[s2.charCodeAt(i) - 97]++; } for (let i = 0; i < s2Len - s1Len; i++) { if (s1Count.toString() === s2Count.toString()) return true; s2Count[s2.charCodeAt(i) - 97]--; s2Count[s2.charCodeAt(i + s1Len) - 97]++; } return s1Count.toString() === s2Count.toString(); } Ставь 👍 и забирай 📚 Базу знаний
Открыть канал и посмотреть медиаSolo los usuarios registrados pueden compartir su opinión.
¡Sé el primero en compartir tu experiencia con este recurso!