-
-
-
-
-
Shopping in Mars is quite a different experience. The Mars people pay
by chained diamonds. Each diamond has a value (in Mars dollars M$).
When making the payment, the chain can be cut at any position for only
once and some of the diamonds are taken off the chain one by one. Once
a diamond is off the chain, it cannot be taken back. For example, if we
have a chain of 8 diamonds with values M$3, 2, 1, 5, 4, 6, 8, 7, and we
must pay M$15. We may have 3 options:
1. Cut the chain between 4 and 6 ...
阅读题目
面试题
经典指数
-
-
-
-
Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.
If such arrangement is not possible, it must rearrange it as the lowest possible order (ie, sorted in ascending order).
The replacement must be in-place, do not allocate extra memory.
Here are some examples. Inputs are in the left-hand column and its corresponding outputs are in the right-hand column.
1,2,3→1,3,2
3,2,1→1,2,3
1,1,5→1,5,1 ...
阅读题目
面试题
经典指数
-
扫描后移动端查看
相关标签
同类标签
|
微信公众号
|
|
欢迎加入,一起群聊
|