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
{"lastUpload":"2019-03-28T01:46:10.783Z","extensionVersion":"v3.2.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
import java.util.ArrayList; | |
import java.util.List; | |
/** | |
* Main | |
*/ | |
public class Main { | |
public static void main(String[] args) { | |
Class<Number> strClz = N2umber.class; | |
Class<Integer> intClz = Integer.class; |
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 IntList { | |
public int first; | |
public IntList rest; | |
public IntList(int first0, IntList rest0) { | |
first = first0; | |
rest = rest0; | |
} | |
/** |
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
/** | |
* Created by JunhaoW on 03/31/2019 | |
*/ | |
public class SLList_Sentinel { | |
private int size; | |
private IntNode sentinel; /* The first item (if it exists) is at sentinel.next */ | |
/* sentinel should not be changed later (after init) */ | |
public SLList_Sentinel() { |
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.util.ArrayList; | |
import java.util.List; | |
/** | |
* Created by JunhaoW on 05/06/2019 | |
*/ | |
public class MyBTree<Key extends Comparable<Key>, Value> { | |
/** | |
* 2-3 tree: Order-of-3, 3 children max |
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 List<List<Integer>> permute(int[] nums) { | |
List<List<Integer>> result = new ArrayList<>(); | |
permute(0, nums, result); | |
return result; | |
} | |
private void permute(int depth, int[] nums, List<List<Integer>> result) { | |
// base case |
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 List<List<Integer>> subsets(int[] nums) { | |
List<List<Integer>> result = new ArrayList<>(); | |
List<Integer> numList = new ArrayList<>(); | |
result.add(new ArrayList<>()); // empty set | |
subsets(0, nums, numList, result); | |
return result; | |
} | |
private void subsets(int offset, int[] nums, List<Integer> numList, List<List<Integer>> result) { |
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 BuyAndSellStock { | |
/** | |
* Brute-Force | |
* Time: O(N^2) | |
*/ | |
public static double maxProfitBruteForce(List<Double> prices) { | |
double maxProfit = 0.0; | |
for (int i = 0; i < prices.size(); ++i) { | |
for (int j = i; j < prices.size(); ++j) { |
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 { | |
class ListNode { | |
int val; | |
ListNode oldNode = null; // point to old max node | |
ListNode prev = null; | |
ListNode next = null; | |
ListNode(int _val) { val = _val; } | |
} | |
ListNode dummy = new ListNode(0); |
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
/** | |
* Definition for singly-linked list. | |
* public class ListNode { | |
* int val; | |
* ListNode next; | |
* ListNode(int x) { val = x; } | |
* } | |
*/ | |
class Solution { | |
OlderNewer