[LeetCode]Container With Most Water
·
SW개발/코딩테스트
https://leetcode.com/problems/container-with-most-water/description/ Container With Most Water - LeetCode Can you solve this real interview question? Container With Most Water - You are given an integer array height of length n. There are n vertical lines drawn such that the two endpoints of the ith line are (i, 0) and (i, height[i]). Find two lines that toget leetcode.com 문제 분석 주어진 높이와 길이를 가지고 ..
[LeetCode]Longest Palindromic Substring
·
SW개발/코딩테스트
https://leetcode.com/problems/longest-palindromic-substring/ str: max_palindrome = "" for i in range(len(s)): # this if for odd length palindrome sub = self.check_palindrome(s, i, i) if len(sub) > len(max_palindrome): max_palindrome = sub # this is for even length palindrome sub = self.check_palindrome(s, i, i+1) if len(sub) > len(max_palindrome): max_palindrome = sub return max_palindrome def c..
[LeetCode]Longest Substring Without Repeating Characters
·
SW개발/코딩테스트
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
·
SW개발/코딩테스트
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
·
SW개발/코딩테스트
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
·
SW개발/코딩테스트
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
·
SW개발/코딩테스트
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
·
SW개발/코딩테스트
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
·
SW개발/코딩테스트
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
·
SW개발/코딩테스트
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칸만 오를 수 있다고 가정하면, 계단을 오르는 총 방..