今天做了几个外企的算法题有点郁闷!
感觉好像也不是很难就是不会呢???
太郁闷了!!!!
1.Assume you have two singly linked lists, denoted as L1 and L2. It is possible that L1 and L2
meet on some node and have a common tail. If L1 has m nodes and L2 has n nodes, then what is
the best time complexity to check if the two linked lists meet and to find out the meeting point?
(Only O(1) constant amont of extra storage space is allowed.)
A. O((m+n)*log(m+n))
B. O(m*n)
C. O(m+n)
D. O((m+n)*log(m*n))
E. O(log(m*n))
2. Tjere are n green buckets and n red buckets. Each green bucket is of a different size, but for
every green bucket, there is a corresponding red bucket of the dame size. What is the AVERAGE
time complexity to find all matching buckets pairs(red and green bucket of the same size) if the
comparisons between buckets of same color are forbiden. (Only O(1) constant amount of extra
storage space is allowed.)
A. O(n)
B. O(log(n))
C. O(n*n)
D. O(nlog(n))
E. None of the above
请大家帮忙分析一下。