Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit e8d6824

Browse files
committed
dd
1 parent 339d403 commit e8d6824

File tree

3 files changed

+28
-4
lines changed

3 files changed

+28
-4
lines changed

LeetCode/Blind75/BestTimeToBuyAndSellStock.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ public static int maxProfit(int[] prices) {
1313
return 0;
1414
}
1515

16-
int lowestValDay= Integer.MAX_VALUE;
17-
int profit=0;
16+
int lowestValDay= Integer.MAX_VALUE; //current lowest value day
17+
int profit=0;
1818
int profitIfSoldToday=0;
1919

2020
for(int i=0; i< prices.length; i++){

LeetCode/Blind75/TwoSum.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ public static void main(String[] args) {
2222

2323
public static int[] twoSum(int[] nums, int target){
2424
int[] result= new int[2]; //array that will store both numbers
25-
Map<Integer, Integer> map= new HashMap<Integer, Integer>();
25+
Map<Integer, Integer> map= new HashMap<Integer, Integer>(); //will store the value at index as key and value as index so we can fetch later if there is a key that contains the difference between target and a number in the array
2626
for(int i=0; i< nums.length; i++){
27-
if(map.containsKey(target-nums[i])){ //
27+
if(map.containsKey(target-nums[i])){ // there is a key in map where target - nums[i] exist
2828
result[1]=i;
2929
result[0]=map.get(target-nums[i]);
3030
return result;

LeetCode/Lt203.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*Remove linked list elements that have the same val and variable val */
2+
class ListNode {
3+
int val;
4+
ListNode next;
5+
ListNode() {}
6+
ListNode(int val) { this.val = val; }
7+
ListNode(int val, ListNode next) { this.val = val; this.next = next; }
8+
}
9+
public class Lt203 {
10+
public static void main(String[] args) {
11+
12+
}
13+
14+
public ListNode removeElements(ListNode head, int val) {
15+
if (head == null) return null;
16+
head.next = removeElements(head.next, val);
17+
if(head.val ==val){
18+
return head.next;
19+
}else{
20+
return head;
21+
}
22+
23+
}
24+
}

0 commit comments

Comments
 (0)