Skip to content

Instantly share code, notes, and snippets.

@temirnurdin
temirnurdin / Solution1.java
Created November 23, 2020 14:08
LeetCode - Sort Array By Parity Solution - Solution#1
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();
@temirnurdin
temirnurdin / Solution.java
Created July 22, 2019 14:10
LeetCode Valid Palindrome Solution
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);