This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function longestWord(token, words) { | |
words = words.sort((a, b) => b.length - a.length); | |
// after sort find will be the longest | |
const longestWord = words.find((word) => { | |
let index = 0; | |
for (let charIndex = 0; charIndex < word.length; charIndex++) { | |
if (!token.slice(index).includes(word[charIndex])) { | |
break; | |
} | |
index = token.slice(index).indexOf(word[charIndex]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import sys | |
import unicodedata | |
def is_vowel(char): | |
_char = unicodedata.normalize('NFKD', char) | |
if _char[0].lower() in 'aeiou': | |
return True | |
return False |