What do you want to save?
Add Code snippet
New code examples
-
Java 2021-10-09 17:10:08
minimum swaps to sort an array
import java.io.*; import java.math.*; import java.util.*; public class Swap { static int minimumSwaps(int[] arr) { int swap=0; boolean visited[]=new boolean[arr.length]; for(int i=0;i<arr.length;i++){ int j=i,cycle=0; while(!visited[j])... Add solution -
Java 2021-10-06 15:49:06
insertion sort java
/** * Insertion sort algorithm, O(n^2) time complexity. */ public static void insertionSort(int[] arr) { int n = arr.length; for(int i = 1; i < n; i++) { int key = arr[i]; int j = i - 1; //shift until you find the position to place the ... Add solution
Best helpers
Ranking is empty