본문 바로가기

Algorithm/알고리즘 문제풀이92

LeetCode 206(Reverse Linked List, java) 0. 문제 https://leetcode.com/problems/reverse-linked-list/ Reverse Linked List - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 1. 문제 설명 - 문제에서 연결 리스트(head)가 주어진다. - 해당 연결 리스트를 역순으로 재 정렬해서 반환하는 것이 문제의 핵심이다. 2. 문제 해설 - 이 문제는 연결 리스트라는 자료구조의 특성과 재귀 함수를 이해하고 있어야 풀 수 있는 문제다. a) 첫 번째 접근 -.. 2022. 4. 17.
LeetCode 203(Removed Linked List Elements, java) 0. 문제 https://leetcode.com/problems/remove-linked-list-elements/ Remove Linked List Elements - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 1. 문제 설명 - 문제에서 연결 리스트(head)와 찾고자 하는 값(val)이 주어진다. - 이 문제의 핵심은 연결 리스트 내부의 모든 노드 중 찾고자 하는 값과 동일한 value를 가진 노드를 삭제하는 것이다. 2. 문제 해설 a) 첫 번째 접근.. 2022. 4. 17.
LeetCode 21(Merge Two Sorted Lists, java) 0. 문제 https://leetcode.com/problems/merge-two-sorted-lists/ Merge Two Sorted Lists - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 1. 문제 설명 - 문제에서 2개의 연결 리스트(list1, list2)가 주어진다. - 두 연결 리스트는 오름차순으로 정렬되어있다. - 두 연결 리스트를 오름차순으로 병합하는 것이 문제의 핵심이다. 2. 문제 해설 a) 첫 번째 접근 - 우선 문제에서 주어진 연결 .. 2022. 4. 15.
LeetCode 141(Linked List Cycle, java) 0. 문제 https://leetcode.com/problems/linked-list-cycle/ Linked List Cycle - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 1. 문제 설명 - 문제에서 한 개의 연결 리스트(head)가 주어진다. - 연결 리스트를 탐색하여 순환이 존재하는지 판단하는 것이 문제의 핵심이다. 2. 문제 해설 - 이 문제는 자칫 어려워 보일 수 있다. - 다만, 문제의 제약조건을 힌트로 사용한다면 굉장히 쉽게 풀리는 문제이다... 2022. 4. 15.
LeetCode 242(Valid Anagram, java) 0. 문제 https://leetcode.com/problems/valid-anagram/ Valid Anagram - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 1. 문제 설명 - 문제에서 2개의 문자열(s, t)이 주어진다. - 문자열 t가 문자열 s의 아나그램인지 판별하는 것이 문제의 핵심이다. 2. 문제 해설 a) 첫 번째 접근 - 우선 각 문자열의 길이를 구한다. - 만약 길이가 동일하지 않다면 아나그램이 될 수 없다. b) 두 번째 접근 - 각 문.. 2022. 4. 15.
LeetCode 383(Ransom Note, java) 0. 문제 https://leetcode.com/problems/ransom-note/ Ransom Note - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 1. 문제 설명 - 문제에서 2개의 문자열(ransomNote, magazine)이 주어진다. - magazine을 구성하는 문자를 이용하여 ransomNote와 동일한 문자열을 만들 수 있는냐가 문제의 핵심이다. 2. 문제 해설 a) 첫 번째 접근 - 이 문제는 Magazine과 ransomNote을 구.. 2022. 4. 14.
LeetCode 387(First Unique Character in a String, java) 0. 문제 https://leetcode.com/problems/first-unique-character-in-a-string/ First Unique Character in a String - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 1. 문제 설명 - 문제에서 문자열(s)이 주어진다. - 문자열을 구성하는 문자 중 가장 첫 번째로 중복이 없는 문자를 찾아 해당 문자의 index를 반환하는 것이 문제의 핵심이다. 2. 문제 해설 - 이 문제를 풀기 위해서.. 2022. 4. 14.
LeetCode 74(Search a 2D Matrix, java) 0. 문제 https://leetcode.com/problems/search-a-2d-matrix/ Search a 2D Matrix - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 1. 문제 설명 - 문제에서 이중 배열(matrix)과 찾고자 하는 숫자(target)가 주어진다. - 이중 배열의 규칙과 구조를 파악하여 target을 찾는 가장 효율정인 탐색 알고리즘을 작성하는 것이 문제의 핵심이다. 2. 문제 해설 a) 첫 번째 접근 - 우선 문제에서 주어지.. 2022. 4. 14.
LeetCode 36(Valid Sudoku, java) 0. 문제 https://leetcode.com/problems/valid-sudoku/ Valid Sudoku - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 1. 문제 설명 - 문제에서 이중 배열(board)이 주어진다. - 이중 배열(board)은 수도쿠 문제를 만들기 위해서 생성된 것이다. - 이 문제의 핵심은 주어진 이중 배열(board)이 수도쿠로써 이상이 없는지 파악하는 것이다. 2. 문제 해설 a) 전제 조건 - 우선 문제에서 주어진 조건을 보자.. 2022. 4. 13.