Want to know:
首先找到最后一段递减的区间反转这段区间然后从这段区间的开头开始找到第一个比这段区间前一个值大的值,交换 int i = len - 1; while(i > 0 && nums[i] <= nums[i - 1]) { i--; } if(i == 0) { Arrays.sort(nums); return; } for(int j = 0; j < (len - i) / 2; j++) { swap(nums, i + j, len - 1 - j); } for(int j = i; j < len; j++){ if(nums[j] > nums[i - 1]) { swap(nums, j, i - 1); break; } }
Get a detailed, AI-powered explanation for this question and thousands more on StudyFetch.
Get the Answer for FreeHow StudyFetch Helps You Master This Topic
AI-Powered Answers
Get instant, detailed explanations powered by AI that understands your course material.
Deep Understanding
Go beyond surface-level answers with step-by-step breakdowns and examples.
Personalized Learning
Spark.E adapts to your learning style and helps you connect ideas.
Practice & Test
Turn any question into flashcards, quizzes, and practice tests to solidify your knowledge.
Explore More Questions
- période post-révolutionnaire ayant eu lieu de septembre 1793 à juillet 1794, apparition de la justice d'exception, recul de la justice civile ordinaire, apparition de tribunaux révolutionnaires, se finit avec la période impériale en 1795
- The rate used in discounting future cash flow; also called the discount rate or opportunity cost of capital.
- Le prix d'équilibre d'un bien est de 10 euros et la quantité échangée à l'équilibre est de 1 million d'unités. Suite à un choc, le prix d'équilibre passe à 12 euros et la quantité d'équilibre passe à 0,9 million d'unités. Quelle est la nature de ce choc ?