This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.util.Arrays; | |
| public class FirstIndexOf { | |
| public static int search(int key, int[] xr) { | |
| for (int i = 0; i < xr.length; i++) { | |
| if (key == xr[i]) { | |
| return i; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.util.Arrays; | |
| public class ValueExist { | |
| public static boolean search(int key, int[] xr) { | |
| for (int i = 0; i < xr.length; i++) { | |
| if (key == xr[i]) { | |
| return true; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.util.Arrays; | |
| public class MaxEnd { | |
| public static void sort(int[] xr) { | |
| for (int i = 0; i < xr.length - 1; i++) { | |
| if (xr[i] > xr[i + 1]) { | |
| int temp = xr[i]; | |
| xr[i] = xr[i + 1]; | |
| xr[i + 1] = temp; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.util.Arrays; | |
| public class ArraySort { | |
| public static void sort(int[] xr) { | |
| for (int i = 0; i < xr.length - 1; i++) { | |
| for (int j = 0; j < xr.length - 1; j++) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.util.Arrays; | |
| public class ArraySort { | |
| public static void sort(int[] xr) { | |
| for (int i = 0; i < xr.length - 1; i++) { | |
| for (int j = 0; j < xr.length - 1; j++) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.util.Arrays; | |
| public class ArraySort { | |
| public static void sort(int[] xr) { | |
| for (int i = xr.length - 1; i > 0; i--) { | |
| for (int j = 0; j < i; j++) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.util.Arrays; | |
| public class MergeTwoArray { | |
| public static int[] mergeTwoArrays(int[] xr, int[] yr) { | |
| int[] newArray = new int[xr.length + yr.length]; | |
| for (int i = 0; i < xr.length; i++) { | |
| newArray[i] = xr[i]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.util.Scanner; | |
| public class TwoDArray { | |
| public static void main(String[] args) { | |
| Scanner input = new Scanner(System.in); | |
| System.out.print("Input number of students: "); | |
| int student = input.nextInt(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class ReversedString { | |
| public static void main(String[] args) { | |
| String input = "GitHub Gist Page"; | |
| // String Covert into an array | |
| char[] stringArray = input.toCharArray(); | |
| for (int i = 0, j = stringArray.length - 1; i < j; i++, j--) { | |
| char temp = stringArray[i]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class CheckArray { | |
| public static boolean isExists(int[] xr, int[] yr) { | |
| int i = 0; | |
| int j = 0; | |
| while (i < xr.length && j < yr.length) { | |
| if (xr[i] == yr[j]) { | |
| i++; |