- Today
- Total
목록leetcode (186)
작심삼일
문제 링크: https://leetcode.com/problems/pascals-triangle/ 문제 Given an integer numRows, return the first numRows of Pascal's triangle. In Pascal's triangle, each number is the sum of the two numbers directly above it as shown: 조건 1
문제 링크: https://leetcode.com/problems/max-area-of-island/ 문제 You are given an m x n binary matrix grid. An island is a group of 1's (representing land) connected 4-directionally (horizontal or vertical.) You may assume all four edges of the grid are surrounded by water. The area of an island is the number of cells with a value 1 in the island. Return the maximum area of an island in grid. If ther..
문제 링크: https://leetcode.com/problems/construct-binary-tree-from-preorder-and-inorder-traversal/ 문제 Given two integer arrays preorder and inorder where preorder is the preorder traversal of a binary tree and inorder is the inorder traversal of the same tree, construct and return the binary tree. 조건 1

문제 링크: https://leetcode.com/problems/binary-tree-level-order-traversal/ 문제 Given the root of a binary tree, return the level order traversal of its nodes' values. (i.e., from left to right, level by level). 조건 The number of nodes in the tree is in the range [0, 2000]. -1000 List[List[int]]: if not root: return [] ans = [[]] def traversal(root, depth): if not root: return if len(ans) > depth: ans..
문제 링크: https://leetcode.com/problems/matchsticks-to-square/ 문제 You are given an integer array matchsticks where matchsticks[i] is the length of the ith matchstick. You want to use all the matchsticks to make one square. You should not break any stick, but you can link them up, and each matchstick must be used exactly one time. Return true if you can make this square and false otherwise. 조건 1 tar..

문제 링크: https://leetcode.com/problems/binary-tree-right-side-view/ 문제 Given the root of a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see ordered from top to bottom. 조건 The number of nodes in the tree is in the range [0, 100]. -100

문제 링크: https://leetcode.com/problems/interleaving-string/ 문제 Given strings s1, s2, and s3, find whether s3 is formed by an interleaving of s1 and s2. An interleaving of two strings s and t is a configuration where they are divided into non-empty substrings such that: s = s1 + s2 + ... + sn t = t1 + t2 + ... + tm |n - m|
문제 링크: https://leetcode.com/problems/fibonacci-number/ 문제 The Fibonacci numbers, commonly denoted F(n) form a sequence, called the Fibonacci sequence, such that each number is the sum of the two preceding ones, starting from 0 and 1. That is, F(0) = 0, F(1) = 1 F(n) = F(n - 1) + F(n - 2), for n > 1. Given n, calculate F(n). 조건 0 int: fi = [0]*31 fi[1] = 1 for idx in range(2, n+1): fi[idx] = fi[i..