코딩 테스트(JAVA)(89)
-
[리트코드] 46. Permutations 순열, 77. Combinations 조합, 78. Subsets 부분집합
46. Permutations 순열문제https://leetcode.com/problems/permutations/description/더보기Example 1:Input: nums = [1,2,3]Output: [[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]] Example 2:Input: nums = [0,1]Output: [[0,1],[1,0]] Example 3:Input: nums = [1]Output: [[1]] Constraints:1 -10 All the integers of nums are unique. 접근 방법주의사항• 순서가 다르면 다른 것으로 인식한다 • 예를 들어, {1,2}와 {2,1}은 다른 것으로 간주하며, 둘 다 선택 가능하다. • ..
2024.07.19 -
[리트코드] 1. Two Sum
문제https://leetcode.com/problems/two-sum/더보기Example 1:Input: nums = [2,7,11,15], target = 9Output: [0,1] Explanation: Because nums[0] + nums[1] == 9, we return [0, 1]. Example 2:Input: nums = [3,2,4], target = 6Output: [1,2] Example 3:Input: nums = [3,3], target = 6Output: [0,1] Constraints:2 -109 -109 Only one valid answer exists.접근 방법아이디어문제에서 오직 1가지 답만 존재한다고 했기에 중복 정답은 존재하지 않는다. 모든 경우를 조사해야 하므로..
2024.07.17 -
[문제15][LeetCode] 206. 역순 연결 리스트
https://leetcode.com/problems/reverse-linked-list/description/ Given the head of a singly linked list, reverse the list, and return the reversed list. Constraints: The number of nodes in the list is the range [0, 5000] -5000
2024.04.06 -
[문제14][LeetCode] 21. 두 정렬 리스트의 병합
https://leetcode.com/problems/merge-two-sorted-lists/ You are given the heads of two sorted linked lists list1 and list2. Merge the two lists into one sorted list. The list should be made by splicing together the nodes of the first two lists. Return the head of the merged linked list. Constraints: The number of nodes in both lists is in the range [0, 50]. -100
2024.04.06 -
[문제13][LeetCode] 234. 팰린드롬 연결 리스트
https://leetcode.com/problems/palindrome-linked-list/ Given the head of a singly linked list, return true if it is a palindrome or false otherwise. * A palindrome is a sequence that reads the same forward and backward. Example 1: Input: head = [1,2,2,1] Output: true Example 2: Input: head = [1,2] Output: false Constraints: The number of nodes in the list is in the range [1, 10⁵] 0
2024.04.04 -
[programmers] 삼각 달팽이
https://school.programmers.co.kr/learn/courses/30/lessons/68645 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 정수 n이 매개변수로 주어집니다. 다음 그림과 같이 밑변의 길이와 높이가 n인 삼각형에서 맨 위 꼭짓점부터 반시계 방향으로 달팽이 채우기를 진행한 후, 첫 행부터 마지막 행까지 모두 순서대로 합친 새로운 배열을 return 하도록 solution 함수를 완성해 주세요. 제한사항 n은 1 이상 1,000 이하입니다. 입출력 예 n result 4 [1,2,9,3,10,8,4,5,6,7] 5 [1,2..
2024.03.30