전체 글(236)
-
[LeetCode] Valid Mountain Array (Python)
보호되어 있는 글입니다.
2024.02.29 -
[LeetCode] Check If N and Its Double Exist (Python)
class Solution: def checkIfExist(self, arr: List[int]) -> bool: for i in range(len(arr)): for j in range(len(arr)): if i != j: if arr[i] == 2 * arr[j]: return True return False
2024.02.29 -
[LeetCode] Remove Duplicates from Sorted Array (Python)
class Solution: def removeDuplicates(self, nums: List[int]) -> int: if len(nums)==0: return 0 i=0 for j in range(1,len(nums)): if nums[i]!=nums[j]: i+=1 nums[i]=nums[j] return i+1
2024.02.27 -
[LeetCode] Remove Element (Python)
class Solution: def removeElement(self, nums: List[int], val: int) -> int: i = 0 for j in range(len(nums)): if nums[j] != val: nums[i] = nums[j] i += 1 return i
2024.02.27 -
[LeetCode] Merge Sorted Array (Python)
class Solution: def merge(self, nums1: List[int], m: int, nums2: List[int], n: int) -> None: N1 = nums1[:m] N2 = nums2[:n] for i in range(len(N2)): N1.append(N2[i]) num1 = sorted(N1) for i in range(len(num1)): nums1[i] = num1[i] """ Do not return anything, modify nums1 in-place instead. """
2024.02.27 -
[LeetCode] Duplicate Zeros (Python)
class Solution: def duplicateZeros(self, arr: List[int]) -> None: temp = [] for i in range(len(arr)): if arr[i] == 0: temp.append(arr[i]) temp.append(arr[i]) answer = temp[:len(arr)] for i in range(len(arr)): arr[i] = answer[i]
2024.02.27