916. Word Subsets
Instead of dictionary, we can use an array of 26. Every medium has it’s own easy and hard…
Instead of dictionary, we can use an array of 26. Every medium has it’s own easy and hard…
思路 按大自然的写法不难,问题在于需要了解”\t” “\n”是一个字符而不是两个。以及比起从前往后数数,用lstrip更快。 贴图的写法要点:对于不同路径,depth字典是会变的,但相同路径没有影响。 Stack方法:0 – 0, 0.1 – 0, 0.1, 0.1.1 – 0, 0.1, 0.1.1, 0.1.2 – 0, 0.2 (计算深度,当深度小于栈尾时,代表进入了另一个路径,把非路径的pop出栈)- 0, 0.2, 0.2.1
Just practice writing Trie.
Not hard. Should be aware of Boarder Cases ( numFrends == 1)
Don’t forget mod when dealing with shifting. A negative number a: a % b = (a + b) % b Anyway, easy makes me…
This easy is easier than yesterday’s easy. New tech: str.find(sub) / str.rfind(sub). find the first/last index of sub. if sub == “”, return 0/n;…