분류 전체보기
[LeetCode]Longest Substring Without Repeating Characters
https://leetcode.com/problems/longest-substring-without-repeating-characters/ int: # 문자열이 고유한 단어들로만 이루어진 경우, 문자열의 길이 자체가 정답입니다. if len(set(s)) == len(s): return len(s) substring = '' max_len = 1 for i in s: # substring에 들어있지 않은 문자인 경우에만 substring을 추가하고, max_len 값을 업데이트 합니다. if i not in substring: substring = substring + i max_len = max(max_len, len(substring)) # 이미 substring에 있는 문자가 다시 등장한다면 # 이..
[LeetCode]Add Two Numbers
https://leetcode.com/problems/add-two-numbers/ Add Two Numbers - LeetCode Can you solve this real interview question? Add Two Numbers - You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order, and each of their nodes contains a single digit. Add the two numbers and leetcode.com 문제 분석 두개의 숫자 리스트 노드가 주어질 때 더하는 문제입니다. 처음 시도한 답안 # Defin..
[LeetCode]Pascal's Triangle
https://leetcode.com/problems/pascals-triangle/ Pascal's Triangle - LeetCode Can you solve this real interview question? Pascal's 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: [https://upload.wikimedia.o leetcode.com 문제 분석 파스칼의 삼각형을 구하는 문제입니다. 처음 시도한 답안 class Solution..
[LeetCode]Maximum Depth of Binary Tree
https://leetcode.com/problems/maximum-depth-of-binary-tree/ Maximum Depth of Binary Tree - LeetCode Can you solve this real interview question? Maximum Depth of Binary Tree - Given the root of a binary tree, return its maximum depth. A binary tree's maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf leetcode.com 문제 분석 트리에서 가장 긴 depth 값을 구하는 문..
[LeetCode]Search Insert Position
https://leetcode.com/problems/search-insert-position/ Search Insert Position - LeetCode Can you solve this real interview question? Search Insert Position - Given a sorted array of distinct integers and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order. You must w leetcode.com 문제 분석 target으로 주어지는 숫자가 nums 배열에 삽입되는 경우 ..
[LeetCode]Symmetric Tree
https://leetcode.com/problems/symmetric-tree/ Symmetric Tree - LeetCode Can you solve this real interview question? Symmetric Tree - Given the root of a binary tree, check whether it is a mirror of itself (i.e., symmetric around its center). Example 1: [https://assets.leetcode.com/uploads/2021/02/19/symtree1.jpg] Input: roo leetcode.com 문제 분석 이진트리가 주어졌을 때 대칭구조를 가지는 트리인지 구하는 문제입니다. 처음 시도한 답안 # De..
[LeetCode]Binary Tree Inorder Traversal
https://leetcode.com/problems/binary-tree-inorder-traversal/description/ Binary Tree Inorder Traversal - LeetCode Can you solve this real interview question? Binary Tree Inorder Traversal - Given the root of a binary tree, return the inorder traversal of its nodes' values. Example 1: [https://assets.leetcode.com/uploads/2020/09/15/inorder_1.jpg] Input: root = [1,nu leetcode.com 문제 분석 트리를 중위 순회하고..
[LeetCode]Climbing Stairs
https://leetcode.com/problems/climbing-stairs/ 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 문제 분석 특정 수의 계단이 있을 때 1칸 혹은 2칸만 오를 수 있다고 가정하면, 계단을 오르는 총 방..
[LeetCode]Merge Two Sorted Lists
https://leetcode.com/problems/merge-two-sorted-lists/description/ Merge Two Sorted Lists - LeetCode Can you solve this real interview question? Merge Two Sorted Lists - 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 leetcode.com 문제 분석 두개의 리스트를 오름차순으로 정렬하여 하..
[LeetCode]Valid Parentheses
https://leetcode.com/problems/valid-parentheses/ Valid Parentheses - LeetCode Can you solve this real interview question? Valid Parentheses - Given a string s containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. An input string is valid if: 1. Open brackets must be closed by the sam leetcode.com 문제 분석 괄호의 쌍이 정상적으로 존재하는지 체크하는 문제입니다. 일명, VPS 알고리즘 ..