[Array] Remove Duplicates from Sorted Array
2021. 1. 8. 21:35ㆍ프로그래밍-코딩테스트/LeetCode
Given a sorted array nums, remove the duplicates in-place such that each element appears only once and returns the new length.
Do not allocate extra space for another array, you must do this by modifying the input array in-place with O(1) extra memory.
Clarification:
Confused why the returned value is an integer but your answer is an array?
Note that the input array is passed in by reference, which means a modification to the input array will be known to the caller as well.
간단하다
배열의 유일한 Integer 값들만 떼서 갯수를 리턴하란다
자료구조로 따지면 Set인데 In-place 문제이니 Loop 비교가 답.
경계값인 길이 0일때 경우는 제외해주고
배열이 흐트러지지 않게 하기 위해, 뒤부터 Loop를 돌리는 것만 주의하면 쉬운 문제
'프로그래밍-코딩테스트 > LeetCode' 카테고리의 다른 글
[Array] Sort Array By Parity (0) | 2021.01.08 |
---|---|
[Array] Move Zeroes (0) | 2021.01.08 |
[Array] Replace Elements with Greatest Element on Right Side (0) | 2021.01.06 |
[Array] Valid Mountain Array (0) | 2021.01.06 |
[Array] Check If N and Its Double Exist (0) | 2021.01.06 |