如果不写具体的center,就直接写: U.S. Department of Homeland Security U.S. Citizenship and Immigration Services 是不是可以? 还有看到有的人写的地址是: United States Department of Justice Immigration and Naturalization Service 到底哪个是正确的? 谢谢!
i*h
3 楼
hash是O(N) BST要O(NlgN)吧?
i*3
4 楼
In all letters, I used: U.S. Department of Homeland Security U.S. Citizenship and Immigration Services
我好像跟我之前遇到的题混了一下,但这样似乎也是O(n)? for each x in the array map(x) = N-x index_end = -1 for i in 0..n-1 if exists map(map(array_i)) if index_end == -1 index_end = n-1-i else index_end = min(index_end, n-1-i) if index_end != -1 return (n-1-index_end, index_end)
log(n-1)+log(n-2)+....log(1) = log((n-1)*log(n-2)*...log(1)) =O(nlog(n)) this one should be log(n-1)+log(n-2)+....log(1) = log((n-1)(n-2)...(1))log(n-1) O(nlog(n)) Is this right?
Imput: array A, sum s. Output: pair (u,v) Given an sorted array, choose the middle element m, then m is the root of a balanced BST. If s-m>m, we search the right sub-tree, otherwise we search the left sub-tree. Doing this recursively, we can find (u,v) in O(log(n)).
哦,不好意思,这个不对,有可能 u 在 left subtree,而 v 在 right subtree
a
【在 g**u 的大作中提到】 : Imput: : array A, sum s. : Output: : pair (u,v) : Given an sorted array, choose the middle element m, then m is the root of a : balanced BST. If s-m>m, we search the right sub-tree, otherwise we search : the left sub-tree. Doing this recursively, we can find (u,v) in O(log(n)).
【在 d**e 的大作中提到】 : 我好像跟我之前遇到的题混了一下,但这样似乎也是O(n)? : for each x in the array : map(x) = N-x : index_end = -1 : for i in 0..n-1 : if exists map(map(array_i)) : if index_end == -1 : index_end = n-1-i : else : index_end = min(index_end, n-1-i)