본문 바로가기

코딩테스트

(3)
[Java 자료구조] 스택(Stack) leetcode 20번 문제에서 자료구조로 스택을 사용해야했다. 스택을 공부한지 너무 오래되어 다시 정리하고자 한다. https://joey-program.tistory.com/83 스택이란? 스택은 영어로 '쌓다', '쌓아 올린 더미'를 의미한다. 의미와 동일하게 자료구조의 스택(stack) 역시 비슷한 특징을 지닌다. LIFO(Last In First Out)이라는 특징을 갖는데 예를 들어 긴 발포비타민 통을 생각하면 된다. 한 쪽은 막혀있고 한쪽에서만 비타민을 뺄 수 있는 형식인 것이다. 자바에서는 java.util.Stack 클래스를 통해 stack(스택) 동작을 제공하고 있다. 큐(Queue) 왁 같이 사용해 다양한 문제 해결을 할 수 있다. 스택 사용법 class Solution { publi..
20. Valid Parentheses 난이도 쉬움 Given a string s containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. An input string is valid if: Open brackets must be closed by the same type of brackets. Open brackets must be closed in the correct order. '(', ')', '{', '}', '[' 및 ']' 문자만 포함하는 문자열 s가 주어지면 입력 문자열이 유효한지 확인합니다. 다음과 같은 경우 입력 문자열이 유효합니다. 열린 브래킷은 동일한 유형의 브래킷으로 닫아야 합니다. 열린 브..
9. Palindrome Number 난이도 쉬움 문제 Given an integer x, return true if x is palindrome integer. An integer is a palindrome when it reads the same backward as forward. For example, 121 is a palindrome while 123 is not. Example 1: Input: x = 121 Output: true Explanation: 121 reads as 121 from left to right and from right to left. Example 2: Input: x = -121 Output: false Explanation: From left to right, it reads -121. From ..