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
class Solution { | |
public int[] sortArrayByParity(int[] A) { | |
DoubleSidedStack doubleSidedStack = new DoubleSidedStack(A.length); | |
for (int number : A) { | |
if (number %2 == 0) | |
doubleSidedStack.pushFront(number); | |
else | |
doubleSidedStack.pushBack(number); | |
} | |
return doubleSidedStack.resultStack(); |
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
class Solution { | |
public static boolean isPalindrome(String s) { | |
int i = 0; | |
int j = s.length()-1; | |
boolean result = true; | |
if (s.length() == 0 || s.length() == 1) | |
return true; | |
while(i != j-1) { | |
char tempA = s.charAt(i); | |
char tempB = s.charAt(j); |