Skill Problems
31. Next Permutation
Consider the last permutation: 5-4-3-2-1, all in descending order.
- From right to left, find the first ascending pair nums[i] and nums[i+1], e.g., 12947653, found nums[4]=4.
- From right to left, find the first number nums[j] greater than nums[i], which is 5.
- Swap nums[i] and nums[j], resulting in 12957643. At this point, all numbers after nums[i] are in descending order.
- Sort the numbers after nums[i] in ascending order, resulting in 12953467.
128. Longest Consecutive Sequence
[100,4,200,1,3,2]
The value of a variable in the Cache may be inconsistent with the value in Main Memory, leading to calculation errors.