8000
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent b1d0308 commit be7108eCopy full SHA for be7108e
21-30/27. Remove Element.js
@@ -1,10 +1,15 @@
1
var removeElement = function(nums, val) {
2
+ // we have to return number of elements not equal to val in nums
3
+ // while removing all occurenece of val in place
4
let k = 0
5
+ // run a for loop over nums
6
for(let i = 0; i < nums.length ;i++){
7
+ // when nums[i] is not equal to val assign nums[k] with nums[i]
8
+ // k is position(and counter) for value which are not equal to k
9
if(!(nums[i] == val)){
10
nums[k] = nums[i]
11
k++
12
}
13
14
return k
-};
15
+};
0 commit comments