27. Remove Element
class Solution {
/**
* @param Integer[] $nums
* @param Integer $val
* @return Integer
*/
function removeElement(&$nums, $val) {
foreach($nums as $key => $num){
if ($num === $val){
unset($nums[$key]);
}
}
return count($nums);
}
}
Previous26. Remove Duplicates from Sorted ArrayNext28. Find the Index of the First Occurrence in a String
Last updated