LeetCode 27 - Remove Element (JavaScript)

preview_player
Показать описание

🔖 Sections 🔖
0:00 Problem description
0:44 Understanding the solution
3:15 Solution
4:43 Time & Space Analysis

#leetcode #arrays #datastructuresandalgorithms
Рекомендации по теме
Комментарии
Автор

I still wonder why there are so few followers on your channel.
Please continue in the same spirit.

hrantharutyunyan
Автор

class Solution(object):
def removeElement(self, nums, val):
"""
:type nums: List[int]
:type val: int
:rtype: int
"""
final = 0
for i in nums:
if i != val:

final = final + 1

return final

nikhilg
Автор

const removeElement = (nums, val) => {
nums = nums.filter((num) => num !== val);
return `${nums.length}, nums = ${nums}`;
};

joyelo-oghene
welcome to shbcf.ru