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.util.*; | |
| public class SameTree { | |
| /** | |
| * Definition for a binary tree node. | |
| * public class TreeNode { | |
| * int val; | |
| * TreeNode left; | |
| * TreeNode right; | |
| * TreeNode(int x) { val = x; } |
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.util.Arrays; | |
| import java.util.HashMap; | |
| /** | |
| * Created by xynophon on 15.2.27. | |
| */ | |
| public class majorityElement { | |
| public int majorityElement(int[] num) { | |
| //bad solution using Hash. O(n). it took 343ms. | |
| int half = num.length/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
| import java.util.Scanner; | |
| /** | |
| * Created by xynophon on 15.1.27. | |
| */ | |
| public class roman_2_integer{ | |
| // I 1 | |
| // IV 4 |
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.util.Scanner; | |
| /** | |
| * Created by xynophon on 15.1.27. | |
| */ | |
| public class Unique_Binary_Search_Trees { | |
| public int solution(int n){ | |
| int dbnum = 2*n; | |
| long result = 1; | |
| int cnt = 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
| /** | |
| * Created by xynophon on 15.1.17. | |
| */ | |
| import java.util.Scanner; | |
| public class search { | |
| public int binary_search_iter(int[] arr, int target){ | |
| int lo = 0; | |
| int hi = arr.length; |
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
| /** | |
| * Created by xynophon on 15.1.17. | |
| */ | |
| import java.util.Random; | |
| import java.util.Scanner; | |
| public class sort { | |
| public int[] swap(int[] arr, int i, int j){ | |
| int temp = arr[i]; | |
| arr[i] = arr[j]; |
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.File; | |
| import java.io.FileInputStream; | |
| import java.io.FileNotFoundException; | |
| import java.io.FileOutputStream; | |
| import java.io.IOException; | |
| import java.io.InputStream; | |
| import java.nio.ByteBuffer; | |
| import java.util.HashMap; | |
| import android.util.Log; |
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.util.Scanner; | |
| /** | |
| * Created by xynophon on 15.1.14. | |
| */ | |
| public class Excelsheetcolumnnumber { | |
| public int titleToNumber(String s) { | |
| int num = s.charAt(0)-64; | |
| for(int i = 1; i < s.length(); i++){ | |
| num = 26 * num + (s.charAt(i)-64); |
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.util.Scanner; | |
| /** | |
| * Created by xynophon on 15.1.13. | |
| */ | |
| public class FactorialTrailingZeroes { | |
| public long trailingZeroes(int n) { | |
| int count = 0; | |
| if(n < 1) return 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
| /** | |
| * Created by xynophon on 15.1.13. | |
| */ | |
| public class binary_search { | |
| public int binary_search(double[] arr, double target){ | |
| int lo = 0; | |
| int hi = arr.length; | |
| while(lo+1 < hi){ | |
| int mid = (lo+hi)/2; |