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 com.yekmer.interview.intercom; | |
import java.util.LinkedList; | |
import java.util.Queue; | |
public class NestedArrays { | |
public static void main(String[] args) { | |
//sample for this output [[1,2,[3]],4] -> [1,2,3,4] | |
Object[] objArr = new Object[2]; |
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 com.yekmer.interview.intercom; | |
import java.io.BufferedReader; | |
import java.io.FileReader; | |
import java.util.PriorityQueue; | |
import java.util.Stack; | |
public class TopNumbers { | |
public static void main(String[] args) { |
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 DeepestDepth { | |
static DeepestDepth ts = new DeepestDepth(); | |
static Node maxNode; | |
static int maxDepth = 0; | |
public static void main(String[] args) { | |
Node l1221 = ts.new Node(null, null, 8); | |
Node l122 = ts.new Node(null, l1221, 4); | |
Node l121 = ts.new Node(null, null, 7); |
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 PrintLevel { | |
static PrintLevel ts = new PrintLevel(); | |
public static void main(String[] args) { | |
Node l122 = ts.new Node(null, null, 4); | |
Node l121 = ts.new Node(null, null, 7); | |
Node r12 = ts.new Node(null, null, 4); | |
Node l12 = ts.new Node(l122, l121, 5); | |
Node l11 = ts.new Node(null, null, 2); |
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 SwapLinkedList { | |
static SwapLinkedList sll = new SwapLinkedList(); | |
public static void main(String[] args) { | |
// 1->2->3->4->5->6 | |
Node node6 = sll.new Node(null, 6); | |
Node node5 = sll.new Node(node6, 5); | |
Node node4 = sll.new Node(node5, 4); | |
Node node3 = sll.new Node(node4, 3); | |
Node node2 = sll.new Node(node3, 2); | |
Node root = sll.new Node(node2, 1); |
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 ChessPath { | |
private static int length = 4; | |
public static void main(String[] args) { | |
String headStr = ""; | |
getPath(1, 0, false, headStr); | |
getPath(0, 1, true, headStr); | |
} | |
public static void getPath(int xC, int yC, boolean upD, String path) { | |
if(xC == length || yC == length) 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
public class Palindrome { | |
public static void main(String[] args) { | |
String st = "abcecba"; | |
System.out.println(isPalindrome(st)); | |
} | |
public static boolean isPalindrome(String st) { | |
for(int i = 0; i < st.length() - i - 1; i++) { | |
if(st.charAt(i) != st.charAt(st.length() - 1 - i)) { |
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 com.yekmer.geeksforgeeks; | |
class TreeSum { | |
static TreeSum ts; | |
static int sum = 0; | |
public static void main(String[] args) { | |
ts = new TreeSum(); | |
Node l122 = ts.new Node(null, null, 4); |
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 static Node lca(Node node, int a, int b) { | |
while (node != null) { | |
if(a > node.value && b > node.value) { | |
node = node.right; | |
} else if (a < node.value && b < node.value) { | |
node = node.left; | |
} else { | |
return node; | |
} | |
} |
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.io.InputStream; | |
import java.net.URL; | |
import android.content.Context; | |
import android.content.res.Resources; | |
import android.graphics.Bitmap; | |
import android.graphics.Canvas; | |
import android.graphics.Color; | |
import android.graphics.Paint; | |
import android.graphics.PorterDuff; | |
import android.graphics.PorterDuffXfermode; |