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 MissingInteger { | |
| public int minMissingInteger(int[] A) { | |
| if(A == null || A.length == 0) { | |
| return -1; | |
| } | |
| int[] items = new int[A.length + 1]; | |
| for(int i = 0; i < items.length; i++) { | |
| items[i] = -1; | |
| } |
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 PermCheck { | |
| public int checkIfIsPermutation(int[] A) { | |
| if(A == null || A.length == 0) { | |
| return -1; | |
| } | |
| int[] passed = new int[A.length]; | |
| for(int i = 0; i < passed.length; i++) { | |
| passed[i] = -1; | |
| } |
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 FrogRiverOne { | |
| public int solution(int X, int[] A) { | |
| if(A == null || A.length == 0) { | |
| return -1; | |
| } | |
| int[] passed = new int[X]; | |
| for(int i = 1; i <= passed.length; i++) { | |
| passed[i-1] = -1; | |
| } |
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 PermMissingElem { | |
| public int findMissingElement(int[] A) { | |
| if(A == null || A.length == 0) { | |
| return 1; | |
| } | |
| long N = A.length + 1; | |
| long total = N * (N + 1) / 2; | |
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 TapeEquilibrium { | |
| public int solution(int[] A) { | |
| int start = A[0]; | |
| int end = sum(A) - start; | |
| int minDif = Math.abs(start - end); | |
| for(int i = 1; i < A.length - 1; i++) { | |
| start += A[i]; | |
| end -= A[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 FrogJump { | |
| public int countJumps(int X, int Y, int D) { | |
| if(X > Y) { | |
| return 0; | |
| } | |
| return (int) Math.ceil((Y - X) / (double) D); | |
| } | |
| } |
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 OddOccurrencesInArray { | |
| public int solution(int[] A) { | |
| if(A == null || A.length == 0) { | |
| return 0; | |
| } | |
| if(A.length == 1) { | |
| return A[0]; | |
| } | |
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 BinaryGap { | |
| public int solution(int N) { | |
| int max = 0; | |
| int counter = 0; | |
| boolean isCounting = false; | |
| while(N > 0) { | |
| if((N & 1) == 1) { | |
| if(isCounting) { |
NewerOlder