This file contains 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.Map; | |
import java.util.HashMao; | |
import java.util.Arrays; | |
public class ZeroSum { | |
public int[] zeroSumSubarray(int input[]) { | |
Map<Integer, Integer> lookUpMap = new HashMap<>(); | |
int runningSum = 0; |
This file contains 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 ZeroSum { | |
/* | |
* @param input - integer array | |
* return - longest zero sum subarray list | |
*/ | |
public int[] zeroSumLongest(int[] input) { | |
Map<Integer, Integer> lookUpMap = new HashMap<>(); | |
int runningSum =0; |
This file contains 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.Map; | |
import java.util.HashMap; | |
import java.util.Map; | |
import java.util.HashSet; | |
public class TwoSum { | |
public static Set<Integer, Integer> twoSum(int targetSum, int input[]) { | |
Map<Integer, Integer> map = new HashMap<>(); | |
Set<Integer, Integer> results = new HashSet<>(); |
This file contains 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
package kata.string; | |
public class ReplaceBlank { | |
/** | |
* if you can use the String Buffer | |
*/ | |
public String replaceBlankWithStringBuilder(String input) { | |
StringBuilder sb = new StringBuilder(); |
This file contains 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
package kata; | |
import java.util.Arrays; | |
/* | |
* input1 = { 3, 8, 17, 99} | |
* input2 = { 5, 17, 88} | |
* output = { 3, 5, 8, 17, 88, 99} | |
*/ | |
public class MergeSortedArray { |
This file contains 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 ListUtils { | |
class Node { | |
int data; | |
Node next; | |
} | |
public static void print(Node node) { | |
if(node.next ==null ) { | |
return; |
This file contains 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 MaximumSubarray { | |
private int sum(int input[]) { | |
int s = 0; | |
for (int i = 0; i < input.length; i++) { | |
s += input[i]; | |
} | |
return s; |
This file contains 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
package kata.list.reverse; | |
class Node { | |
int value; | |
Node next; | |
public Node(int value, Node next) { | |
this.value = value; | |
this.next = next; | |
} |
This file contains 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
package kata.string; | |
import java.util.Set; | |
import java.util.HashSet; | |
public class ReplaceDuplicates { | |
/* | |
* @param input char array with duplicated characters for example, google | |
* @return output char array with duplicated characters. After removal of duplicated characters output will be gogle |
This file contains 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
package kata.string; | |
public class RemoveDuplicateString { | |
public static String removeDuplicateCharacters(String first, String second) { | |
if (first == null || second == null) { return first; } | |
char[] map = new char[256]; | |
for (int i = 0; i < second.length(); i++) { | |
char ch = second.charAt(i); |
OlderNewer