TGViewer
Python | LeetCode Python | LeetCode @easy_python_task · 9.01K subscribers
Post #1613 1.05K
Задача: 1119. Remove Vowels from a String
Сложность: easy

Дана строка s, удалите из нее гласные 'a', 'e', 'i', 'o' и 'u' и верните новую строку.

Пример:
Input: s = "leetcodeisacommunityforcoders"
Output: "ltcdscmmntyfrcdrs"


👨‍💻 Алгоритм:

1⃣Создайте метод isVowel(), который возвращает true, если переданный символ является одной из гласных [a, e, i, o, u], и false в противном случае.

2⃣Инициализируйте пустую строку ans.

3⃣Пройдитесь по каждому символу в строке s, и для каждого символа c проверьте, является ли он гласной, используя isVowel(c). Если нет, добавьте символ в строку ans. В конце верните строку ans.

😎 Решение:
class Solution:
def removeVowels(self, s: str) -> str:
def isVowel(c):
return c in 'aeiou'

ans = []
for char in s:
if not isVowel(char):
ans.append(char)

return ''.join(ans)


Ставь 👍 и забирай 📚 Базу знаний
  • 👍 3
More from @easy_python_task
  1. Oct 18, 2026Post #2452
  2. Oct 17, 2026Задача: 409. Longest Palindrome Сложность: easy Если задана строка s, состоящая из строчны…
  3. Oct 17, 2026Задача: 1539. Kth Missing Positive Number Сложность: easy Дан массив arr из положительных…
  4. Oct 16, 2026Задача: 1236. Web Crawler Сложность: medium Учитывая url startUrl и интерфейс HtmlParser,…
  5. Oct 15, 2026Задача: 1043. Partition Array for Maximum Sum Сложность: medium Если задан целочисленный м…
  6. Oct 15, 2026Задача: 1474. Delete N Nodes After M Nodes of a Linked List Сложность: easy Вам дано начал…
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →