Skip to content

Commit

Permalink
27. Remove Elemen
Browse files Browse the repository at this point in the history
  • Loading branch information
SE-MahmoudAbdelaal committed May 31, 2024
1 parent 196a8b2 commit 7293679
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions Top Interview 150-leetcode/easy/27. Remove Element/Solution.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/**
* Solution
*/
public class Solution {
public int removeElement(int[] nums, int val) { //0,1,2,2,3,0,4,2 2
int index=0;
for (int i = 0; i < nums.length; i++) {
if (nums[i]!=val) {
nums[index++]=nums[i];

}
}
return index;
}}

0 comments on commit 7293679

Please sign in to comment.