/
iRumba
/
LeetCode
Обзор
Документация
Войти
/
iRumba
/
LeetCode
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
main
RemoveElement27/Solution.cs
35 строк
727 B
iRumba
27 solution
11 ноя 2025, 07:54
11 ноя 2025, 07:54
d2b5269
Код
Авторство
О чём код?
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace RemoveElement27; public class Solution { public int RemoveElement(int[] nums, int val) { var resLength = nums.Length; for(var i = 0; i < resLength; i++) { if (nums[resLength - 1] == val) { resLength--; i--; continue; } if (nums[i] == val) { var tmp = nums[i]; nums[i] = nums[resLength - 1]; nums[resLength - 1] = tmp; resLength--; } } return resLength; } }