[LeetCode] 152. Maximum Product Subarray
·
Problem Solving/LeetCode
출처 : https://leetcode.com/problems/maximum-product-subarray/description/ Maximum Product Subarray - LeetCode Can you solve this real interview question? Maximum Product Subarray - Given an integer array nums, find a subarray that has the largest product, and return the product. The test cases are generated so that the answer will fit in a 32-bit integer. Examp leetcode.com 아래 코드는 브루트포스로 스스로 해결하였..
[LeetCode] 198. House Robber
·
Problem Solving/LeetCode
출처 : https://leetcode.com/problems/house-robber/ House Robber - LeetCode Can you solve this real interview question? House Robber - You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is that adjacent ho leetcode.com 아직 부족하다는 생각이 많이 든 문제였다. DP를 사용하였지만 솔루션을 보면 내가 짠 코드가 무색해..
[LeetCode] 238. Product of Array Except Self
·
Problem Solving/LeetCode
출처 : https://leetcode.com/problems/product-of-array-except-self/description/ Product of Array Except Self - LeetCode Can you solve this real interview question? Product of Array Except Self - Given an integer array nums, return an array answer such that answer[i] is equal to the product of all the elements of nums except nums[i]. The product of any prefix or suffix of nu leetcode.com 접근법을 몰라서 풀지..
[LeetCode] 36. Valid Sudoku
·
Problem Solving/LeetCode
출처 : https://leetcode.com/problems/valid-sudoku/description/ Valid Sudoku - LeetCode Can you solve this real interview question? Valid Sudoku - Determine if a 9 x 9 Sudoku board is valid. Only the filled cells need to be validated according to the following rules: 1. Each row must contain the digits 1-9 without repetition. 2. Each c leetcode.com 내 풀이 : class Solution: def isValidSudoku(self, boa..
[LeetCode] 347. Top K Frequent Elements
·
Problem Solving/LeetCode
출처 : https://leetcode.com/problems/top-k-frequent-elements/ Top K Frequent Elements - LeetCode Can you solve this real interview question? Top K Frequent Elements - Given an integer array nums and an integer k, return the k most frequent elements. You may return the answer in any order. Example 1: Input: nums = [1,1,1,2,2,3], k = 2 Output: [1,2] leetcode.com 방법 1) 우선순위 큐를 사용한 풀이 class Solution: ..
[LeetCode] 746. Min Cost Climbing Stairs
·
Problem Solving/LeetCode
출처 : https://leetcode.com/problems/min-cost-climbing-stairs/description/?envType=study-plan-v2&envId=dynamic-programming Min Cost Climbing Stairs - LeetCode Can you solve this real interview question? Min Cost Climbing Stairs - You are given an integer array cost where cost[i] is the cost of ith step on a staircase. Once you pay the cost, you can either climb one or two steps. You can either sta..
[LeetCode] 49. Group Anagrams
·
Problem Solving/LeetCode
https://leetcode.com/problems/group-anagrams/description/ Group Anagrams - LeetCode Can you solve this real interview question? Group Anagrams - Given an array of strings strs, group the anagrams together. You can return the answer in any order. An Anagram is a word or phrase formed by rearranging the letters of a different word or phrase leetcode.com class Solution: def groupAnagrams(self, strs..
[LeetCode] 2811. Check if it is Possible to Split Array
·
Problem Solving/LeetCode
https://leetcode.com/problems/check-if-it-is-possible-to-split-array/description/ 지난 주 위클리 B번 문제.(해결하지 못했다.) 아주 코포스러운 문제(?)라고 한다. 문제에서 요구하는 근본적인 문제를 해결한다면 간단한 구현으로 풀이가 가능했다. 1. 두 개 합쳐서 m이상인 길이 2의 배열이 하나도 없을 때 왜 불가능한가? ex) arr =[2,1,1,1] m = 4 문제에서 요구하는대로 진행하다보면 결국 길이 1의 subarray가 각각 1개씩, 총 2개가 남아야한다. 그러기 위해선 이전 단계에서 [길이가 2인 m보다 크거나 같은 합을 가진 subarray] , [길이가 1인 subarray]에서 split이 이루어져야 한다. 하지만 예로..
[LeetCode] 33. Search in Rotated Sorted Array.
·
Problem Solving/LeetCode
https://leetcode.com/problems/search-in-rotated-sorted-array/ Search in Rotated Sorted Array - LeetCode Can you solve this real interview question? Search in Rotated Sorted Array - There is an integer array nums sorted in ascending order (with distinct values). Prior to being passed to your function, nums is possibly rotated at an unknown pivot index k (1
[LeetCode] 88. Merge Sorted Array
·
Problem Solving/LeetCode
출처 : https://leetcode.com/problems/merge-sorted-array/ Merge Sorted Array - LeetCode Can you solve this real interview question? Merge Sorted Array - You are given two integer arrays nums1 and nums2, sorted in non-decreasing order, and two integers m and n, representing the number of elements in nums1 and nums2 respectively. Merge nums1 an leetcode.com class Solution { public void merge(int[] nu..
[LeetCode] 83. Remove Duplicates from Sorted List
·
Problem Solving/LeetCode
출처 : https://leetcode.com/problems/remove-duplicates-from-sorted-list/ Remove Duplicates from Sorted List - LeetCode Can you solve this real interview question? Remove Duplicates from Sorted List - Given the head of a sorted linked list, delete all duplicates such that each element appears only once. Return the linked list sorted as well. Example 1: [https://assets.le leetcode.com /** * Definiti..
[LeetCode] 94. Binary Tree Inorder Traversal
·
Problem Solving/LeetCode
출처 : https://leetcode.com/problems/binary-tree-inorder-traversal/ 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 /** * Definition for a b..