SW개발/코딩테스트

    [LeetCode]Remove Nth Node From End of List

    https://leetcode.com/problems/remove-nth-node-from-end-of-list/ Remove Nth Node From End of List - LeetCode Can you solve this real interview question? Remove Nth Node From End of List - Given the head of a linked list, remove the nth node from the end of the list and return its head. Example 1: [https://assets.leetcode.com/uploads/2020/10/03/remove_ex1.jpg] leetcode.com 문제 분석 주어진 링크드 리스트에서 뒤에서 ..

    [LeetCode]Letter Combinations of a Phone Number

    https://leetcode.com/problems/letter-combinations-of-a-phone-number/ Letter Combinations of a Phone Number - LeetCode Can you solve this real interview question? Letter Combinations of a Phone Number - Given a string containing digits from 2-9 inclusive, return all possible letter combinations that the number could represent. Return the answer in any order. A mapping of d leetcode.com 문제 분석 번호가 ..

    [LeetCode]3Sum

    https://leetcode.com/problems/3sum/ 3Sum - LeetCode Can you solve this real interview question? 3Sum - Given an integer array nums, return all the triplets [nums[i], nums[j], nums[k]] such that i != j, i != k, and j != k, and nums[i] + nums[j] + nums[k] == 0. Notice that the solution set must not contain du leetcode.com 문제 분석 합이 0이되는 3개의 숫자를 구하는 문제입니다. 중복된 숫자의 사용이 있다면 제외합니다. 처음 시도한 답안 (오답) impor..

    [LeetCode]Container With Most Water

    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

    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

    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 배열에 삽입되는 경우 ..