자료구조와 알고리즘/LeetCode 문제풀이
-
Valid Parentheses자료구조와 알고리즘/LeetCode 문제풀이 2020. 6. 26. 13:27
Given a string 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. Note that an empty string is also considered valid. 문장 안에 여는 괄호가 있을 때 ,그 뒤에 알맞는 닫는 괄호가 있는지 검사하는 알고리즘을 만드는 문제이다. 1. 여는 괄호와 닫는 괄호를 매치시켜야 되므로 H..
-
Two Sum자료구조와 알고리즘/LeetCode 문제풀이 2020. 6. 24. 13:11
Given an array of integers, return indices of the two numbers such that they add up to a specific target. You may assume that each input would have exactly one solution, and you may not use the same element twice. 예시) int[] numbers = {1,1,3}; int target = 2; int[] result = solution(numbers, target); // [0, 1] System.out.println(Arrays.toString(result)); 풀이) 정수형 배열에 속하는 두 정수를 더해서 target과 같을 때, 두 ..