- Today
- Total
목록분류 전체보기 (387)
작심삼일
문제 링크: https://leetcode.com/problems/palindrome-partitioning/ 문제 Given a string s, partition s such that every substring of the partition is a palindrome. Return all possible palindrome partitioning of s. A palindrome string is a string that reads the same backward as forward. 조건 1
문제 링크: https://leetcode.com/problems/complement-of-base-10-integer/ 문제 The complement of an integer is the integer you get when you flip all the 0's to 1's and all the 1's to 0's in its binary representation. For example, The integer 5 is "101" in binary and its complement is "010" which is the integer 2. Given an integer n, return its complement. 조건 0 int: if n == 0: return 1 ans = 0 cur = 1 wh..
문제 링크: https://leetcode.com/problems/find-the-town-judge/ 문제 In a town, there are n people labeled from 1 to n. There is a rumor that one of these people is secretly the town judge. If the town judge exists, then: The town judge trusts nobody. Everybody (except for the town judge) trusts the town judge. There is exactly one person that satisfies properties 1 and 2. You are given an array trust w..
문제 링크: https://leetcode.com/problems/smallest-integer-divisible-by-k/ 문제 Given a positive integer k, you need to find the length of the smallest positive integer n such that n is divisible by k, and n only contains the digit 1. Return the length of n. If there is no such n, return -1. Note: n may not fit in a 64-bit signed integer. 조건 1
문제 링크: https://leetcode.com/problems/populating-next-right-pointers-in-each-node/ 문제 You are given a perfect binary tree where all leaves are on the same level, and every parent has two children. The binary tree has the following definition: struct Node { int val; Node *left; Node *right; Node *next; } Populate each next pointer to point to its next right node. If there is no next right node, th..

문제 링크: https://www.acmicpc.net/problem/2638 문제 N×M (5≤N, M≤100)의 모눈종이 위에 아주 얇은 치즈가 과 같이 표시되어 있다. 단, N 은 세로 격자의 수이고, M 은 가로 격자의 수이다. 이 치즈는 냉동 보관을 해야만 하는데 실내온도에 내어놓으면 공기와 접촉하여 천천히 녹는다. 그런데 이러한 모눈종이 모양의 치즈에서 각 치즈 격자(작 은 정사각형 모양)의 4변 중에서 적어도 2변 이상이 실내온도의 공기와 접촉한 것은 정확히 한시간만에 녹아 없어져 버린다. 따라서 아래 모양과 같은 치즈(회색으로 표시된 부분)라면 C로 표시된 모든 치즈 격자는 한 시간 후에 사라진다. 와 같이 치즈 내부에 있는 공간은 치즈 외부 공기와 접촉하지 않는 것으로 가정한다. 그러므 ..
문제 링크: https://leetcode.com/problems/merge-intervals/ 문제 Given an array of intervals where intervals[i] = [starti, endi], merge all overlapping intervals, and return an array of the non-overlapping intervals that cover all the intervals in the input. 조건 1
문제 링크: https://leetcode.com/problems/number-complement/ 문제 The complement of an integer is the integer you get when you flip all the 0's to 1's and all the 1's to 0's in its binary representation. For example, The integer 5 is "101" in binary and its complement is "010" which is the integer 2. Given an integer num, return its complement. 조건 1 int: ans = 0 cur = 1 while num > 1: a, b = num//2, nu..