본문 바로가기

전체 글

(206)
Leetcode[two pointer] 3Sum 풀어보기 https://leetcode.com/problems/3sum/submissions/2167042503/ 3Sum - LeetCodeCan 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 duleetcode.com문제는 배열의 원소 a, b, c의 합이 0인 값을 찾는 것입니다. 다만 배열 원소의 조합이 중복되어..
Leetcode[Hash] Longest Consecutive Sequence 풀어보기 https://leetcode.com/problems/longest-consecutive-sequence/submissions/2166160484/ Longest Consecutive Sequence - LeetCodeCan you solve this real interview question? Longest Consecutive Sequence - Given an unsorted array of integers nums, return the length of the longest consecutive elements sequence. You must write an algorithm that runs in O(n) time. Example 1: Input:leetcode.com 연속된 수열을 찾는 ..
[Leetcode][PrefixSum] Merge Intervals 풀어보기 https://leetcode.com/problems/product-of-array-except-self/submissions/2163925484/ 오늘의 문제는 누적합을 사용하는 문제입니다. 실제로 따지고 보면 합은 아니지만 형태는 그런 방식입니다.각 answer[i]에는 본인 nums[i]를 제외한 나머지 모든 값을 곱한 결과를 저장해야합니다. 문제의 조건은 O(n)의 복잡도를 사용하면서 division operation을 사용하지 않는것입니다.만약 division을 사용할 수 있다면, 모두 곱하고 필요한 값만 나누면 되기 때문에 매우 쉽게 해결할 수 있는데 이 경우를 회피하기 위함인것으로 보입니다. 본인 외의 모든 값을 곱하는 것을 반복한다면 쉽게 결과를 얻을 수 있겠지만 이 경우는 O(n^2..
[Leetcode][Greedy] Merge Intervals 풀어보기 https://leetcode.com/problems/merge-intervals/submissions/ Merge Intervals - LeetCodeCan you solve this real interview question? Merge Intervals - Given an array of intervals where intervals[i] = [starti, endi], merge all overlapping intervals, and return an array of the non-overlapping intervals that cover all the intervals in the inputleetcode.com간단한 그리디 문제입니다. 일단은 주어지는 2차원 배열이 정렬된 상태는 아니이기에 정..
[LeetCode][Dijkstra] NetworkDelayTime 풀어보기 https://leetcode.com/problems/network-delay-time/submissions/?utm_source=chatgpt.com Network Delay Time - LeetCodeCan you solve this real interview question? Network Delay Time - You are given a network of n nodes, labeled from 1 to n. You are also given times, a list of travel times as directed edges times[i] = (ui, vi, wi), where ui is the source node, vi is the tarleetcode.com 이번 문제는 다익스트라 알고..
[LeetCode][DFS] Find Eventual 어쩌구 풀어보기 https://leetcode.com/problems/find-eventual-safe-states/submissions/2153038558/ Find Eventual Safe States - LeetCodeCan you solve this real interview question? Find Eventual Safe States - There is a directed graph of n nodes with each node labeled from 0 to n - 1. The graph is represented by a 0-indexed 2D integer array graph where graph[i] is an integer array of nodesleetcode.com처음에는 terminal n..
[LeetCode][Union-Find] Redundant Connection 풀어보기 https://leetcode.com/problems/redundant-connection/description/?utm_source=chatgpt.com Redundant Connection - LeetCodeCan you solve this real interview question? Redundant Connection - In this problem, a tree is an undirected graph that is connected and has no cycles. You are given a graph that started as a tree with n nodes labeled from 1 to n, with one additional edge aleetcode.com Union-Find를..
[LeetCode][DP] House Robber 풀어보기 https://leetcode.com/problems/house-robber/description/ House Robber - LeetCodeCan 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 holeetcode.com 가장 간단한 형태의 Dynamic Programming 문제입니다.DP문제는 DP임을 파악..