Because list will allow duplicates which are ladder from different words, and the size of the list is much larger than that of the set
ChuntaoLu
@ChuntaoLu
Posts made by ChuntaoLu

RE: Python solution in 578ms

RE: Fast Python solution with backtracking and caching + DP solution
I think string is fine, converting to char array will cause overhead

RE: My Python iterative DFS solution
It is the same as
if node.left is None and node.right is None
, I probably shouldn't code that way, it's shorter but less idiomatic. 
RE: Python DP solution
I think my indexes will work, because
dp[i][j]
means weather the substring of firsti
characters ofp
match the substring of firstj
characters ofs
, inclusively. 
RE: Python recursive solution, 266ms
You are right, the recursive call stack is O(n) deep, so the space is O(n). I have updated the post. Thank you for pointing it out!

RE: DP solution in Python
you are right, when the target is huge it takes a lot of memory with no good use!

RE: Python solutions in divideandconquer and heapq
Because every loop iteration the problem size is reduced by half. Suppose we have 16 linked lists, then the number of linked lists changes as follows: 16 > 8 > 4> 2 > 1

RE: Python solutions in divideandconquer and heapq
The inner loop merges all the linked lists by pairs, and after merging the list get mutated so the outer loop makes sure the updated list are merged too.

RE: Two Python solutions, stack and generator
@zzhu06, no problem.
Keep in mind that binary tree is a recursive data structure.
A node may or may not have a right subtree.
If it has, then we know the next smallest element is in the right subtree, so we need to do the same thing(the while loop) to the right subtree, you can think of this as the 'recursion';
if no right subtree, the next element is the stack top.
Let me know if this makes things clear.