Skip to content

Commit

Permalink
add 27 java
Browse files Browse the repository at this point in the history
  • Loading branch information
yennanliu committed Nov 3, 2024
1 parent 7b7b5ab commit 128faa5
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 11 deletions.
2 changes: 1 addition & 1 deletion data/progress.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
20241103: 26
20241103: 26,27
20241102: 802,1197,26
20241027: 855,846
20241026: 932
Expand Down
18 changes: 9 additions & 9 deletions data/to_review.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
2024-12-28 -> ['26']
2024-12-28 -> ['26,27']
2024-12-27 -> ['802,1197,26']
2024-12-21 -> ['855,846']
2024-12-20 -> ['932']
Expand All @@ -7,7 +7,7 @@
2024-12-13 -> ['298,729']
2024-12-12 -> ['1146']
2024-12-08 -> ['737']
2024-12-07 -> ['26', '686,734,737']
2024-12-07 -> ['26,27', '686,734,737']
2024-12-06 -> ['802,1197,26', '353']
2024-12-05 -> ['528,334']
2024-12-03 -> ['1145']
Expand All @@ -16,25 +16,25 @@
2024-11-27 -> ['951,792', '524,221,889']
2024-11-26 -> ['743,889']
2024-11-25 -> ['837']
2024-11-24 -> ['26']
2024-11-24 -> ['26,27']
2024-11-23 -> ['802,1197,26', '163,1048', '981']
2024-11-22 -> ['298,729', '1087']
2024-11-21 -> ['1146']
2024-11-20 -> ['939']
2024-11-18 -> ['430']
2024-11-17 -> ['855,846', '737', '363']
2024-11-16 -> ['26', '932', '686,734,737', '1032,844,1011']
2024-11-16 -> ['26,27', '932', '686,734,737', '1032,844,1011']
2024-11-15 -> ['802,1197,26', '353', '947']
2024-11-14 -> ['951,792', '528,334']
2024-11-12 -> ['1145', '753']
2024-11-11 -> ['26', '727']
2024-11-11 -> ['26,27', '727']
2024-11-10 -> ['802,1197,26', '163,1048']
2024-11-09 -> ['855,846', '298,729', '1145,1219']
2024-11-08 -> ['26', '932', '1146']
2024-11-08 -> ['26,27', '932', '1146']
2024-11-07 -> ['802,1197,26']
2024-11-06 -> ['26', '951,792', '524,221,889']
2024-11-05 -> ['26', '802,1197,26', '743,889']
2024-11-04 -> ['26', '802,1197,26', '855,846', '737', '837', '659']
2024-11-06 -> ['26,27', '951,792', '524,221,889']
2024-11-05 -> ['26,27', '802,1197,26', '743,889']
2024-11-04 -> ['26,27', '802,1197,26', '855,846', '737', '837', '659']
2024-11-03 -> ['802,1197,26', '932', '686,734,737', '801,552']
2024-11-02 -> ['163,1048', '353', '981', '1057,1066,1110']
2024-11-01 -> ['855,846', '951,792', '298,729', '528,334', '1087']
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public class RemoveDuplicatesFromSortedArray {
* [1,2, 1] if nums[f] != nums[s], move s, then swap f, s
* s s f
*
*
*
* //--------------------------------
* Example 2
* //--------------------------------
Expand Down
55 changes: 55 additions & 0 deletions leetcode_java/src/main/java/dev/workspace5.java
Original file line number Diff line number Diff line change
Expand Up @@ -2388,6 +2388,61 @@ public int removeDuplicates(int[] nums) {
// return s;
// }

// LC 27
// https://leetcode.com/problems/remove-element/description/
/**
* exp 1
*
* nums = [3,2,2,3], val = 3
*
* [3,2,2,3]
* s
* f
*
* [2,3,2,3] if nums[f] != val, swap
* s s
* f
*
* [2,2,3,3] if nums[f] != val, swap
* s s
* f
*
* [2,2,3,3]
* s s
* f
*
*
* exp 2
* nums = [0,1,2,2,3,0,4,2], val = 2
*
*
* [0,1,2,2,3,0,4,2] if nums[f] != val, move s, f
* s f
*
* [0,1,2,2,3,0,4,2] if nums[f] == val, swap
* s
* f
*
*/
public int removeElement(int[] nums, int val) {

int s = 0;
for (int f = 0; f < nums.length; f++){
if (nums[f] != val){
// // do sth
// int tmp = nums[f];
// nums[f] = nums[s];
// nums[s] = tmp;
// //s += 1;
nums[s] = nums[s];
s+=1;
}
//s += 1;
}

return s;
}

}


0 comments on commit 128faa5

Please sign in to comment.