Yesterday mobile phone update wp8.1 into a brick, to take to HTC after the sale of the motherboard (HTC after the sale of very good OH), get back and then upgrade. Received a giant network of written notice, to go to Shanghai, no matter go, do some algorithm first to say it, find some basic questions put up:
1. Write a function, exchange the value of two variables, do not use the third variable.
2. Suppose a up stairs, can cross 1, 2 or 3 layers at a time, ask a up to 50 steps, how many kinds of walk method.
Assuming a up-stairs, it can span 1, 2, 3 layers at a time. or M layer, ask a on the N-level steps, how many ways to go.
where M and n are all positive integers, and M <= N, M <=, N <= 50
Please program to solve this problem, and explain the idea of solving problems in detail.
3. Please design a set of algorithms for all n-character permutations.
If the algorithm outputs a full order sequence, the number is labeled separately, from 1 to n!
So, given the low, high, can not calculate all permutations, and directly output the low to the first high of the arrangement.
Please write the sample code and explain the idea of the problem in detail.
4. A building has n-storey, to go to each level of the number of p[1], p[2], ..., p[n], if the elevator only stop 1 times, ask to stop which floor, you can let everyone walk the least.
If the energy consumption on the road floor is K1, the energy consumed by the next floor is K2, and the energy consumed by the elevator on the floor is K3, ask which layer to stop, which will let everyone consume the least energy.
Please program to solve this problem, and explain the idea of solving problems in detail.