array 9

[LeetCode] Array > Two Sum

leetcode.com/explore/interview/card/top-interview-questions-easy/92/array/546/ Explore - LeetCode LeetCode Explore is the best place for everyone to start practicing and learning on LeetCode. No matter if you are a beginner or a master, there are always new topics waiting for you to explore. leetcode.com 풀이 2중 for문을 통해 Brute-Force를 진행하면 해결할 수 있지만, 이를 조금 개선하여 해결 배열 내 x, y의 합이 target이 되려면 x를 기준으로 ..

[LeetCode] Array > Plus One

https://leetcode.com/explore/interview/card/top-interview-questions-easy/92/array/559/ Explore - LeetCode LeetCode Explore is the best place for everyone to start practicing and learning on LeetCode. No matter if you are a beginner or a master, there are always new topics waiting for you to explore. leetcode.com 풀이 deque라이브러리를 사용하여 큐를 만들고 각 자릿수가 10을 넘으면 다음 자릿수를 추가하거나 한자리 올려주는 식으로 하려고 하다가, 그냥 단순 ..

[LeetCode] Array > Intersection of Two Arrays II

leetcode.com/explore/interview/card/top-interview-questions-easy/92/array/674/ Explore - LeetCode LeetCode Explore is the best place for everyone to start practicing and learning on LeetCode. No matter if you are a beginner or a master, there are always new topics waiting for you to explore. leetcode.com 풀이 처음에는 그냥 set자료형의 intersection 함수를 사용하였지만, 반례로 [1,2,2,1] , [2,2]가 존재하였다. 중복되는 숫자가 사라지기 때문에 ..

[LeetCode] Array > Single Number

leetcode.com/explore/interview/card/top-interview-questions-easy/92/array/549/ Explore - LeetCode LeetCode Explore is the best place for everyone to start practicing and learning on LeetCode. No matter if you are a beginner or a master, there are always new topics waiting for you to explore. leetcode.com 풀이 배열을 오름차순으로 정렬하여 현재의 수와 다음 수를 비교, 같다면 반복횟수를 +1 해줌. 만약 다르고 반복횟수 또한 1이라면 그것은 Single Number 다..

[LeetCode] Array > Contains Duplicate

leetcode.com/explore/interview/card/top-interview-questions-easy/92/array/578/ Explore - LeetCode LeetCode Explore is the best place for everyone to start practicing and learning on LeetCode. No matter if you are a beginner or a master, there are always new topics waiting for you to explore. leetcode.com 풀이 파이썬의 set 자료형을 사용하여 중복 존재 유무 판단 class Solution: def containsDuplicate(self, nums: List[int..

[LeetCode] Array > Best Time to Buy and Sell Stock II

leetcode.com/explore/featured/card/top-interview-questions-easy/92/array/564/ Explore - LeetCode LeetCode Explore is the best place for everyone to start practicing and learning on LeetCode. No matter if you are a beginner or a master, there are always new topics waiting for you to explore. leetcode.com 풀이 Greedy를 사용하여 문제를 해결하였다. 단순하게 오늘의 가격보다 내일의 가격이 높으면 매도하는 방식으로 가장 높은 이익을 구하였다. class Solution..

[LeetCode] Array > Remove Duplicates from Sorted Array

leetcode.com/explore/featured/card/top-interview-questions-easy/92/array/727/ Explore - LeetCode LeetCode Explore is the best place for everyone to start practicing and learning on LeetCode. No matter if you are a beginner or a master, there are always new topics waiting for you to explore. leetcode.com 풀이 정렬된 배열에서 중복을 제거하는 것이 문제이다. 가장 간단한 방법은 set에 담아 중복을 제거하고 list로 변환 후 정렬을 하는 것이 가장 간단할 것이다. 하지..

반응형