분류 전체보기

    [LeetCode]Single Number

    https://leetcode.com/problems/single-number/ Single Number - LeetCode Can you solve this real interview question? Single Number - Given a non-empty array of integers nums, every element appears twice except for one. Find that single one. You must implement a solution with a linear runtime complexity and use only constant leetcode.com 문제 분석 주어진 nums 리스트에서 한번만 등장하는 숫자를 찾는 문제입니다. 처음 시도한 답안 class So..

    [LeetCode]Best Time to Buy and Sell Stock

    https://leetcode.com/problems/best-time-to-buy-and-sell-stock/ Best Time to Buy and Sell Stock - LeetCode Can you solve this real interview question? Best Time to Buy and Sell Stock - You are given an array prices where prices[i] is the price of a given stock on the ith day. You want to maximize your profit by choosing a single day to buy one stock and choosin leetcode.com 문제 분석 주식에 대한 가격이 주어졌을 ..

    [LeetCode]Swap Nodes in Pairs

    https://leetcode.com/problems/swap-nodes-in-pairs/ Swap Nodes in Pairs - LeetCode Can you solve this real interview question? Swap Nodes in Pairs - Given a linked list, swap every two adjacent nodes and return its head. You must solve the problem without modifying the values in the list's nodes (i.e., only nodes themselves may be chan leetcode.com 문제 분석 서로 인접해있는 노드를 뒤집는 문제입니다. 단, 값을 바꾸는 것이 아니라 링..

    [LeetCode]Generate Parentheses

    https://leetcode.com/problems/generate-parentheses/description/ Generate Parentheses - LeetCode Can you solve this real interview question? Generate Parentheses - Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses. Example 1: Input: n = 3 Output: ["((()))","(()())","(())()","()(())","()()()"] Exa leetcode.com 문제 분석 주어진 n개의 괄호를 가지고 가능한 괄호의 조합을 모..

    [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에 있는 문자가 다시 등장한다면 # 이..