목록LeetCode (567)
넘치게 채우기
https://leetcode.com/problems/contiguous-array/description/ Leetcode - Contiguous Array 문제 유형 : 부분합, 해시 문제 난이도 : Medium 문제 Given a binary array nums, return the maximum length of a contiguous subarray with an equal number of 0 and 1. 바이너리 배열 nums가 주어진다. 0과 1의 개수가 같은 부분배열의 최대 길이를 구하시오. 풀이 부분합을 이용하여 풀 수 있다. 해시맵을 만들어서 총합-인덱스의 형태로 저장한다. 배열을 순회하면서, 총합에 0이면 -1을, 1이면 1을 추가한다. 만약 총합이 0이라면, 처음부터 i인덱스까지 조..
https://leetcode.com/problems/remove-zero-sum-consecutive-nodes-from-linked-list/description/ Leetcode - Remove Zero Sum Consecutive Nodes from Linked List 문제 유형 : 연결리스트, 재귀 문제 난이도 : Medium 문제 Given the head of a linked list, we repeatedly delete consecutive sequences of nodes that sum to 0 until there are no such sequences. After doing so, return the head of the final linked list. You may retur..
https://leetcode.com/problems/custom-sort-string/description/ Leetcode - Custom Sort String 문제 유형 : 문자열 처리, 정렬, 그리디 문제 난이도 : Medium 문제 You are given two strings order and s. All the characters of order are unique and were sorted in some custom order previously. Permute the characters of s so that they match the order that order was sorted. More specifically, if a character x occurs before a char..
https://leetcode.com/problems/intersection-of-two-arrays/description/ Leetcode - Intersection of Two Arrays 문제 유형 : 해시, 그리디 문제 난이도 : Easy 문제 Given two integer arrays nums1 and nums2, return an array of their intersection. Each element in the result must be unique and you may return the result in any order. 두 정수배열 nums1과 nums2가 주어진다. 교차점을 반환하시오. 결과의 각 요소는 값이 겹치면 안되고, 순서는 상관없습니다. 풀이 해시맵에 nums1의 요소..
https://leetcode.com/problems/minimum-common-value/description/ Leetcode - Minimum Common Value 문제 유형 : 그리디, 투포인터 문제 난이도 : Easy 문제 Given two integer arrays nums1 and nums2, sorted in non-decreasing order, return the minimum integer common to both arrays. If there is no common integer amongst nums1 and nums2, return -1. Note that an integer is said to be common to nums1 and nums2 if both arrays h..
https://leetcode.com/problems/count-elements-with-maximum-frequency/description/ Leetcode - Count Elements With Maximum Frequency 문제 유형 : 해시, 그리디 문제 난이도 : Easy 문제 You are given an array nums consisting of positive integers. Return the total frequencies of elements in nums such that those elements all have the maximum frequency. The frequency of an element is the number of occurrences of that ele..
https://leetcode.com/problems/middle-of-the-linked-list/description/ Leetcode - Middle of the Linked List 문제 유형 : 연결리스트, 투포인터 문제 난이도 : Easy 문제 Given the head of a singly linked list, return the middle node of the linked list. If there are two middle nodes, return the second middle node. 단순 연결리스트의 헤드가 주어진다. 중간 노드를 반환하라. 두 개의 중앙 노드가 있다면, 두 번째 중앙 노드를 반환하라. 풀이 투 포인터를 이용해서 풀어주면 된다. 두 칸씩 이동하는 fast 한 칸..
https://leetcode.com/problems/minimum-length-of-string-after-deleting-similar-ends/description/ Minimum Length of String After Deleting Similar Ends - LeetCode Can you solve this real interview question? Minimum Length of String After Deleting Similar Ends - Given a string s consisting only of characters 'a', 'b', and 'c'. You are asked to apply the following algorithm on the string any number o..
https://leetcode.com/problems/bag-of-tokens/description/ Leetcode - Bag of Tokens 문제 유형 : 그리디, 투포인터, 정렬 문제 난이도 : Medium 문제 You start with an initial power of power, an initial score of 0, and a bag of tokens given as an integer array tokens, where each tokens[i] donates the value of tokeni. Your goal is to maximize the total score by strategically playing these tokens. In one move, you can play ..
https://leetcode.com/problems/remove-nth-node-from-end-of-list/description/ 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 - R..