Skip to content

Instantly share code, notes, and snippets.

View sharathkumar106's full-sized avatar

SharathKumar sharathkumar106

View GitHub Profile
@sharathkumar106
sharathkumar106 / Example_2_BinarySort
Created September 6, 2020 08:57
Java program to sort a binary array in linear time - three approaches
import java.util.Arrays;
public class Example_2_BinarySort {
// Naive Approach
public static void binarySort_Naive(int[] arr) {
// Iterate through the array and count the number of 0's
int zeroes = 0;
for(int value : arr) {
@sharathkumar106
sharathkumar106 / Example_1_Code
Last active September 5, 2020 12:55
Java program for finding sum pair in an array
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
public class Example_1_PairSum {
// Naive Method
public static void findPair_Naive(int[] arr, int sum) {
// Iterate through the array except last element