본문 바로가기

코딩테스트/LeetCode20

[Python][LeetCode] letter Combinations of a phone number(전화번호 문자 조합) https://leetcode.com/problems/letter-combinations-of-a-phone-number/ 문제 설명: 2에서 9까지 숫자가 주어졌을 때 전화번호로 조합 가능한 모든 문자를 출력하는 문제 이 문제는 전체를 탐색해서 푸는 조합 문제이다. dic = { "2": "abc", "3": "def", "4": "ghi", "5": "jkl", "6": "mno", "7": "pqrs", "8": "tuv", "9": "wxyz", "0": "+" } 자판기에 다음과 같이 있다고 했을때 '23' 을 입력받으면 'ad' , 'ae', 'af', 'bd', 'be', 'bf', 'cd', 'cd', 'cf' 3*3 = 9개 출력을 하면 된다. 풀이 path = '' 를 정의하고 path.. 2024. 1. 17.
[Python][LeetCode] Climbing Stairs(계단오르기) https://leetcode.com/problems/climbing-stairs/description/ Climbing Stairs - LeetCode Can you solve this real interview question? Climbing Stairs - 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 Outpu leetcode.com 문제설명: 정상에 도달하기 위해 n 계단을 올라가야 한다. 정상에 도달하기 위한 .. 2023. 11. 4.
[Python][LeetCode] Intersection of Two Arrays(두 배열의 교집합) https://leetcode.com/problems/intersection-of-two-arrays/description/ Intersection of Two Arrays - LeetCode Can you solve this real interview question? Intersection of Two Arrays - Given two integer arrays nums1 and nums2, return an array of their intersection. Each element in the result must be unique and you may return the result in any order. Example 1: In leetcode.com 문제 설명: 두 배열이 주어졌을때 교집합을.. 2023. 11. 1.
[Python][LeetCode] Search in Rotated Sorted Array(회전 정렬된 배열 검색) https://leetcode.com/problems/search-in-rotated-sorted-array/description/ Search in Rotated Sorted Array - LeetCode Can you solve this real interview question? Search in Rotated Sorted Array - There is an integer array nums sorted in ascending order (with distinct values). Prior to being passed to your function, nums is possibly rotated at an unknown pivot index k (1 nums[right]: left = mid+1 el.. 2023. 11. 1.