Back to Browse

Stream of Characters (Leetcode 1032)

600 views
Apr 8, 2020
10:52

amazon, google, microsoft, facebook, netflix, apple. coding interview Please watch Trie data structure concept first before watching this video: https://www.youtube.com/watch?v=DHYOru6Y5tI Stream of Characters Hard Implement the StreamChecker class as follows: StreamChecker(words): Constructor, init the data structure with the given words. query(letter): returns true if and only if for some k greater-than-or-equals 1, the last k characters queried (in order from oldest to newest, including this letter just queried) spell one of the words in the given list. Example: StreamChecker streamChecker = new StreamChecker(["cd","f","kl"]); // init the dictionary. streamChecker.query('a'); // return false streamChecker.query('b'); // return false streamChecker.query('c'); // return false streamChecker.query('d'); // return true, because 'cd' is in the wordlist streamChecker.query('e'); // return false streamChecker.query('f'); // return true, because 'f' is in the wordlist streamChecker.query('g'); // return false streamChecker.query('h'); // return false streamChecker.query('i'); // return false streamChecker.query('j'); // return false streamChecker.query('k'); // return false streamChecker.query('l'); // return true, because 'kl' is in the wordlist

Download

0 formats

No download links available.

Stream of Characters (Leetcode 1032) | NatokHD