Skip to content

Instantly share code, notes, and snippets.

View criskgl's full-sized avatar
👨‍💻
Coding...

criskgl

👨‍💻
Coding...
View GitHub Profile
void main() {
List<String> myList = ['One', 'Two', 'Three'];
Parent papa = Parent(questions: myList);
Child child = Child(myList);
print(child._questions);
print(child.qn);
@criskgl
criskgl / gist:dbb23dcb3231ec9670c058da956a2b30
Created August 5, 2020 07:03
Return values from async function
```
dffd
```
/*************NODE CLASS*********************/
public class ListNode {
int key;
int value;
ListNode next;
ListNode prev;
public ListNode(){
}
public int[][] kClosest(int[][] points, int K) {
int N = points.length;
int[] dists = new int[N];
for (int i = 0; i < N; ++i)
dists[i] = dist(points[i]);
Arrays.sort(dists);
int distK = dists[K-1];
int[][] ans = new int[K][2];
public static class Wrapper{
public static ArrayList<ArrayList<Integer>> paths;
public static ArrayList<Integer> mins;
public static int max;
}
public static int maxScore2D(int[][] grid){
Wrapper.paths = new ArrayList<ArrayList<Integer>>();
Wrapper.mins = new ArrayList<Integer>();
Wrapper.max = 0;
ArrayList<Integer> path = new ArrayList<>();
class Solution {
TreeNode answer;
public TreeNode lowestCommonAncestor(TreeNode root, TreeNode p, TreeNode q) {
this.answer = new TreeNode(-1);
LCA(root, p, q);
return this.answer;
}
public boolean LCA(TreeNode root, TreeNode p, TreeNode q){
if(root.right == null && root.left == null){//leaf
public TreeNode insertIntoBST(TreeNode root, int val) {
TreeNode tNode = new TreeNode(val);
TreeNode current = root;
while(true){
if(val > current.val){
//BIGGER
if(current.right == null){//insert
current.right = tNode;
break;
}
public String[] reorderLogFiles(String[] logs) {
if (logs == null || logs.length == 0) return logs;
int len = logs.length;
List<String> letterList = new ArrayList<>();
List<String> digitList = new ArrayList<>();
for (String log : logs) {
if (log.split(" ")[1].charAt(0) < 'a') {
digitList.add(log);
} else {
letterList.add(log);
public int minMeetingRooms(int[][] intervals) {
int n = intervals.length;
int[] start = new int[n];
int[] end = new int[n];
for(int i = 0; i < n; i++){
start[i] = intervals[i][0];
end[i] = intervals[i][1];
}
Arrays.sort(start);
Arrays.sort(end);
public int trap(int[] h) {
int n = h.length;
//edge cases--TODO
if(n == 0 || n == 1) return 0;
HashMap<Integer, ArrayList<Integer>> map = new HashMap<Integer, ArrayList<Integer>>();//heights to Indices
boolean leftZeroes = true;
for(int i = 0; i < n; i++){
//ignore left zeroes
if(h[i] == 0) continue;
//Fill map height --> [idx1, idx2, ...]