문제 Given a triangle array, return the minimum path sum from top to bottom. For each step, you may move to an adjacent number of the row below. More formally, if you are on index i on the current row, you may move to either index i or index i + 1 on the next row. 예시 Example 1: Input: triangle = [[2],[3,4],[6,5,7],[4,1,8,3]] Output: 11 Explanation: The triangle looks like: 2 3 4 6 5 7 4 1 8 3 The ..
문제 You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is that adjacent houses have security systems connected and it will automatically contact the police if two adjacent houses were broken into on the same night. Given an integer array nums representing the amount of mo..
문제 You are climbing a staircase. It takes n steps to reach the top. Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top? 예시 Example 1: Input: n = 2 Output: 2 Explanation: There are two ways to climb to the top. 1. 1 step + 1 step 2. 2 steps Example 2: Input: n = 3 Output: 3 Explanation: There are three ways to climb to the top. 1. 1 step + 1 step + 1 s..
5월 23일 (월) 오늘 한 일 leetCode 풀기 70. Climbing Stairs 첫 시도는 직관적으로 도전했으나, 들어오는 값이 커지면 그 처리를 어떻게 해야할 지 감이 잡히지 않아 3 이상의 값 처리를 어떻게 하는지 참고하려고 discuss를 보았다. 대부분의 사람들이 피보나치 수열로 해결하는 것을 보고 NeetCode의 해결 영상을 보고 나도 피보나치 수열을 사용해보았다. 이해하면 쉽지만 이런 문제를 처음 마주치는 사람이라면 바로 생각해내지 못할 것 같았다. (우선 내가 그렇다.) 198. House Robber 위의 문제와 비슷하게 다음 노드를 탐색하며, 그 과정에서 Math.max를 이용하여 최대값을 구하는 알고리즘을 구현하였다. NeetCode의 도움을 받았다. 120. Triangle..
https://leetcode.com/problems/letter-case-permutation/ Letter Case Permutation - 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 문제 Given a string s, you can transform every letter individually to be lowercase or uppercase to create another string. Return a list of all possible str..
문제 Given an array nums of distinct integers, return all the possible permutations. You can return the answer in any order. 예시 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
문제 Given two integers n and k, return all possible combinations of k numbers out of the range [1, n]. You may return the answer in any order. 예시 Example 1: Input: n = 4, k = 2 Output: [ [2,4], [3,4], [2,3], [1,2], [1,3], [1,4], ] Example 2: Input: n = 1, k = 1 Output: [[1]] 제약 조건 Constraints: 1
문제 You are given the heads of two sorted linked lists list1 and list2. Merge the two lists in a 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. 예시 Example 1: Input: list1 = [1,2,4], list2 = [1,3,4] Output: [1,1,2,3,4,4] Example 2: Input: list1 = [], list2 = [] Output: [] Example 3: Input: list1 = [], list2..
Comment