From 60bbfbd92fdc56fba13d58282f13924b95d9fea9 Mon Sep 17 00:00:00 2001 From: WJ_Kim <74583354+mw7895la@users.noreply.github.com> Date: Fri, 27 Jan 2023 18:48:21 +0900 Subject: [PATCH] =?UTF-8?q?=E2=97=86=E2=97=861~N,=20=EC=9E=84=EC=9D=98=20?= =?UTF-8?q?=EC=88=9C=EC=97=B4=EC=9D=98=20=EB=8B=A4=EC=9D=8C=EC=88=9C?= =?UTF-8?q?=EC=97=B4=20=EA=B5=AC=ED=95=98=EA=B8=B0=E2=97=86=E2=97=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 4 1 3 2 4 -> 1 3 4 2 --- BAEKJOON_10972 | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 BAEKJOON_10972 diff --git a/BAEKJOON_10972 b/BAEKJOON_10972 new file mode 100644 index 0000000..db3c7ce --- /dev/null +++ b/BAEKJOON_10972 @@ -0,0 +1,60 @@ +import java.io.*; +import java.util.*; + + +public class Main { + //1 3 2 4 + public static boolean next_permutation(int[] arr){ + int i = arr.length-1; + + while(i>0 && arr[i-1] >= arr[i]){ + i-=1; + } + + if(i<=0){ + return false; + } + + int j =arr.length-1; + while(arr[j] <= arr[i-1]){ + j-=1; + } + + int temp = arr[i-1]; + arr[i-1] = arr[j]; + arr[j] =temp; + + j=arr.length-1; + while(i