본문 바로가기

코딩테스트55

백준 1874번. 스택수열 https://www.acmicpc.net/problem/1874 1874번: 스택 수열 1부터 n까지에 수에 대해 차례로 [push, push, push, push, pop, pop, push, push, pop, push, push, pop, pop, pop, pop, pop] 연산을 수행하면 수열 [4, 3, 6, 8, 7, 5, 2, 1]을 얻을 수 있다. www.acmicpc.net 문제설명 : ex ) 4 3 6 8 7 5 2 1 을 입력했을때 수열을 만들 수 있는지 수열이 되는지 확인해보는 문제이다. 스택으로 문제를 풀어본다. * 4 : 4까지 스택에 push(총 4번) 해준다. 그럼 스택은 LIFO 이기 때문에 스택의 TOP는 4가 될 것 그리고 찾아야 할 숫자 4 같으면 pop 해준다. .. 2023. 10. 18.
Valid Parentheses https://leetcode.com/problems/valid-parentheses/ Valid Parentheses - LeetCode Can you solve this real interview question? Valid Parentheses - Given a string s containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. An input string is valid if: 1. Open brackets must be closed by the sam leetcode.com 문제설명: 문자에 () [] {} 이렇게 제거해나가서 대칭이 모두 맞으면 true 대칭이 .. 2023. 10. 18.
[LeetCode] GroupAnagrams https://leetcode.com/problems/group-anagrams/ Group Anagrams - LeetCode Can you solve this real interview question? Group Anagrams - Given an array of strings strs, group the anagrams together. You can return the answer in any order. An Anagram is a word or phrase formed by rearranging the letters of a different word or phrase leetcode.com 문제설명 : 문자열이 있을때 같은문자가 들어있는 경우 그룹(리스트)로 묶어 정답 리스트에 추가한다. .. 2023. 10. 17.