Tag: Medium
2657. Find the Prefix Common Array of Two Arrays
I hope every lc problems I encounter in the future will be as simple as this one. Single Pass with Frequency Array
3419. Minimize the Maximum Edge Weight of Graph
‘Node 0 must be reachable from all other nodes.’ means 0 is the root of a tree. And because we are going to remove…
916. Word Subsets
Instead of dictionary, we can use an array of 26. Every medium has it’s own easy and hard…
388. Longest Absolute File Path
思路 按大自然的写法不难,问题在于需要了解”\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
3403. Find the Lexicographically Largest String From the Box I
Not hard. Should be aware of Boarder Cases ( numFrends == 1)
3404. Count Special Subsequences
Point: Turn multiplication to fraction Hard to realize “for r in range(4, n – 2): q = r – 2” part.