## 向各位大侠请教几道面试题的思路

原帖地址：mitbbs

想请教大侠们这几道题的最优解答应该是什么？随便哪题给点思路也好。先说声谢谢了！

1. Given an array of elements, return an array of values pertaining to how

many elements are greater than that element remaining in the array.

Ex. [3,4,5,9,2,1, 3], return [3, 2, 1, 0, 1, 1, 0]

First element is 3 because 3<4,5,9. Second element is 2 because 4< 5,9 etc
2. Given a string which only contains lowercase. You need delete the
repeated letters only leave one, and try to make the lexicographical order
of new string is smallest.
Ex. bcabc
Delete the first 'b' and first 'c', the new string will be abc which is
smallest.
3. Given 2 large number A and B, create a new number C using the digits
from A which needs to be grater than B.
e.g. A = 5281, B = 7443
C = 8125.
4. Given an integer:N and an array int arr[], you have to add some
elements to the array so that you can generate from 1 to N by using
(add) the elements in the array.
Please keep in mind that you can only use each element in the array once
when generating a certain x (1<=x<=N). Return the count of the least adding
numbers.
For example:
N=6, arr = [1, 3]
1 is already in arr.
add 2 to the arr.
3 is already in arr
4 = 1 + 3
5 = 2 + 3
6 = 1 + 2 + 3
So we return 1 since we only need to add one element which is 2.