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
void main() { | |
List<String> myList = ['One', 'Two', 'Three']; | |
Parent papa = Parent(questions: myList); | |
Child child = Child(myList); | |
print(child._questions); | |
print(child.qn); |
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
``` | |
dffd | |
``` |
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
/*************NODE CLASS*********************/ | |
public class ListNode { | |
int key; | |
int value; | |
ListNode next; | |
ListNode prev; | |
public ListNode(){ | |
} |
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 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]; |
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 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<>(); |
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
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 |
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 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; | |
} |
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 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); |
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 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); |
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 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, ...] |
NewerOlder