본문 바로가기

알고리즘35

[알고리즘] LeetCode - Contains Duplicate II Contains Duplicate II - LeetCode Can you solve this real interview question? Contains Duplicate II - Given an integer array nums and an integer k, return true if there are two distinct indices i and j in the array such that nums[i] == nums[j] and abs(i - j) 2023. 8. 31.
[알고리즘] LeetCode - Two Sum Two Sum - LeetCode Can you solve this real interview question? Two Sum - Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target. You may assume that each input would have exactly one solution, and you may not leetcode.com 문제 설명 정수형 배열 nums가 주어진다. 두 숫자의 합인 정수형 변수 target이 주어진다. nums안의 두 숫자를 더해 target되는 경우에 두 수의 인덱스를 정수형 배열 형태로 반환한다... 2023. 8. 31.
[알고리즘] LeetCode - Evaluate Reverse Polish Notation Evaluate Reverse Polish Notation - LeetCode Can you solve this real interview question? Evaluate Reverse Polish Notation - You are given an array of strings tokens that represents an arithmetic expression in a Reverse Polish Notation [http://en.wikipedia.org/wiki/Reverse_Polish_notation]. Evaluate t leetcode.com 문제 설명 역 폴란트 표기법이라고 하지만 쉽게 말해 후위 표기법이다. 후위 표기법으로 주어진 식이 문자형 배열로 주어진다. 후위표기법으로 표기된 식을 .. 2023. 8. 31.
[알고리즘] LeetCode - Min Stack Min Stack - LeetCode Can you solve this real interview question? Min Stack - Design a stack that supports push, pop, top, and retrieving the minimum element in constant time. Implement the MinStack class: * MinStack() initializes the stack object. * void push(int val) pushes t leetcode.com 문제 설명 push, pop, top 반환, stack에서의 최솟값 반환을 지원하는 스택을 설계해야 한다. 기능에 해당하는 로직을 구현해야 한다. 문제 해결 별도의 Nodo에 val과 push.. 2023. 8. 31.
[알고리즘] Programmers - 풍선 터트리기 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 문제 설명 일렬로 나열된 n개의 풍선이 정수형 배열로 a로 주어진다. 모든 풍선은 서로 다른 숫자가 써져 있다. 다음과 같은 과정을 반복하면서 풍선들을 단 1개만 남을 때까지 계속 터트린다. 임의의 인접한 두 풍선을 고른 뒤, 두 풍선 중 하나를 터트린다. 터진 풍선으로 인해 풍선들 사이에 빈 공간이 생겼다면, 빈 공간이 없도록 중앙으로 밀착시킨다. 인접한 두 풍선 중에서 번호가 더 작은 풍선을 터트리는 행위는 최대 1번만 할 수 있다. (어떤 시점에서 작은 것을 터트렸다면 그 뒤로는 큰 것만 터트릴 수 있다.. 2023. 8. 28.