- Today
- Total
목록스터디 (250)
작심삼일
문제 링크: https://leetcode.com/problems/remove-k-digits/ 문제 Given string num representing a non-negative integer num, and an integer k, return the smallest possible integer after removing k digits from num. 조건 1 0 and k > 0 and digit 0: ans.pop() k -= 1 ans = ''.join(ans).lstrip('0') if ans == '': return '0' return ans

문제 링크: https://leetcode.com/problems/combination-sum/ 문제 Given an array of distinct integers candidates and a target integer target, return a list of all unique combinations of candidates where the chosen numbers sum to target. You may return the combinations in any order. The same number may be chosen from candidates an unlimited number of times. Two combinations are unique if the frequency of ..
문제 링크: https://leetcode.com/problems/swap-nodes-in-pairs/ 문제 Given a linked list, swap every two adjacent nodes and return its head. You must solve the problem without modifying the values in the list's nodes (i.e., only nodes themselves may be changed.) 조건 The number of nodes in the list is in the range [0, 100]. 0
문제 링크: https://leetcode.com/problems/single-number/ 문제 Given a non-empty array of integers nums, every element appears twice except for one. Find that single one. You must implement a solution with a linear runtime complexity and use only constant extra space. 조건 1
문제 링크: https://leetcode.com/problems/subarray-sum-equals-k/ 문제 Given an array of integers nums and an integer k, return the total number of continuous subarrays whose sum equals to k. 조건 1
문제 링크: https://leetcode.com/problems/k-diff-pairs-in-an-array/ 문제 Given an array of integers nums and an integer k, return the number of unique k-diff pairs in the array. A k-diff pair is an integer pair (nums[i], nums[j]), where the following are true: 0
문제 링크: https://leetcode.com/problems/add-digits/ 문제 Given an integer num, repeatedly add all its digits until the result has only one digit, and return it. 조건 0 int: while len(str(num)) > 1: t_num = 0 for n in str(num): t_num += int(n) num = t_num return num 2) recursion 사용하지 않고 O(1)만에 class Solution: def addDigits(self, num: int) -> int: if num > 9: t_num = 0 for n in str(num): t_num += int(n) ..
문제 링크: https://www.acmicpc.net/problem/4179 문제 지훈이는 미로에서 일을 한다. 지훈이를 미로에서 탈출하도록 도와주자! 미로에서의 지훈이의 위치와 불이 붙은 위치를 감안해서 지훈이가 불에 타기전에 탈출할 수 있는지의 여부, 그리고 얼마나 빨리 탈출할 수 있는지를 결정해야한다. 지훈이와 불은 매 분마다 한칸씩 수평또는 수직으로(비스듬하게 이동하지 않는다) 이동한다. 불은 각 지점에서 네 방향으로 확산된다. 지훈이는 미로의 가장자리에 접한 공간에서 탈출할 수 있다. 지훈이와 불은 벽이 있는 공간은 통과하지 못한다. 입력 입력의 첫째 줄에는 공백으로 구분된 두 정수 R과 C가 주어진다. 단, 1 ≤ R, C ≤ 1000 이다. R은 미로 행의 개수, C는 열의 개수이다. 다음..