Cargando el ejercicio…
A prefix is the beginning of a word, such as "pre" in "prefix". This kind of check is common in search and autocomplete when a user has typed the first few letters. Write a function count_prefixes that receives a list of words and a string pref. Return how many words start with that prefix.
["pay", "attention", "practice", "attend"], "at"2["leetcode", "win", "loops", "success"], "code"0["abc", "abcd", "ab"], "abc"2def count_prefixes(words: list[str], pref: str) -> int:
Inicia sesión para ver tu historial de envíos
Iniciar sesiónInicia sesión para usar el AI Mentor
Iniciar sesión["pay","attention","practice","attend"], "at"2["leetcode","win","loops","success"], "code"0["abc","abcd","ab"], "abc"2[], "x"0["go","good","gone"], "go"3["a","b","c"], ""3