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
import java.lang.Math; | |
import java.util.*; | |
// our main class becomes a file but the main method is still found | |
public class HelloWorld | |
{ | |
public static void main(String[] args) | |
{ | |
ReverseSentence myObject = new ReverseSentence(); | |
String reversed = myObject.reverseString("Hello,, . , I would, like to reverse. . this. sentence, and another thing. Thank You."); |
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
/* | |
Interview Question: | |
Here's a binary tree: write a function to return the count of a certain value in the tree | |
*/ | |
public class TreeNode{ | |
int data; | |
TreeNode left; | |
TreeNode right; | |
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
import java.io.*; | |
import java.util.*; | |
import java.text.*; | |
import java.math.*; | |
import java.util.regex.*; | |
public class Solution { | |
public static void main(String[] args) { | |
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 LinkedList | |
{ | |
public static ListNode head = null; | |
public static void main(String[] args) | |
{ | |
head = new ListNode(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
int x=10; | |
int y=25; | |
System.out.println("x= " + x + " y = " + y); | |
x ^= (y ^= x); | |
y ^= x; | |
System.out.println("x= " + x + " y = " + y); |
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 HeapSort { | |
private static int getLeft(int index) { | |
return index * 2 + 1; | |
} | |
private static int getRight(int index) { | |
return index * 2 + 2; | |
} | |
private static void exchange (int[] arr, int first, int second) { |
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 Main | |
{ | |
public static void main(String[] args) | |
{ | |
BinaryTree tree = new BinaryTree(); | |
tree.add(5); | |
tree.add(4); | |
tree.add(6); | |
tree.add(3); |
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 Main | |
{ | |
public static void main(String[] args) | |
{ | |
MultiplesThreeAndFive myObject = new MultiplesThreeAndFive(); | |
int sum = myObject.getSum(1000); | |
System.out.print("sum: " + sum); | |
} |
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 Main | |
{ | |
public static void main(String[] args) | |
{ | |
EvenFib myObject = new EvenFib(); | |
int sum = myObject.getEvenFibSum(4000000); | |
System.out.print("sum: " + sum); | |
} | |
} |
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 Test | |
{ | |
public static void main(String[] args) | |
{ | |
LargestPrimeFactor myObject = new LargestPrimeFactor(); | |
long largestPrimeFactor = myObject.largestPrimeFactor(600851475143L); | |
System.out.println("largest prime Factor: " + largestPrimeFactor); | |
} | |
} |