목록알고리즘/LeetCode (6)
EPguy
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/bEgVkW/btsFU6kJ0ya/cQ6YwK0jIRyYwIfJGPh5qk/img.png)
문제 There are some spherical balloons taped onto a flat wall that represents the XY-plane. The balloons are represented as a 2D integer array points where points[i] = [xstart, xend] denotes a balloon whose horizontal diameter stretches between xstart and xend. You do not know the exact y-coordinates of the balloons. Arrows can be shot up directly vertically (in the positive y-direction) from diff..
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/t8MI3/btsFRrbOn2B/wIEeYAk0iexSwKfIrEwSJK/img.png)
문제 Given a binary array nums, return the maximum length of a contiguous subarray with an equal number of 0 and 1. 이진배열이 주어질 때, 연속적으로 0과 1의 개수가 똑같은 배열의 최대 길이를 반환하면 됩니다. 예시 Input: nums = [0,1] Output: 2 Explanation: [0, 1] is the longest contiguous subarray with an equal number of 0 and 1. Input: nums = [0,1,0] Output: 2 Explanation: [0, 1] (or [1, 0]) is a longest contiguous subarray with equal n..
문제 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 character y in order, then x should occur before y in the permuted string. Return any permutation of s that satisfies this property. 두 개..
문제 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 element in the array. 양의 정수로 이루어진 배열 nums가 주어집니다. 해당 배열의 원소들 중에서 가장 빈도수가 높은 원소들의 총 빈도수를 반환해야 합니다. 여기서 원소의 빈도수란 해당 원소가 배열에서 등장하는 횟수를 의미합니다. 풀이 1. Count Frequency an..
문제 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. singly linked list가 주어졌을 때 linked list의 가운데 노드를 반환하세요. 만약 두개의 중간 노드가 있을경우 두번째 노드를 반환하세요. 풀이 1. Counting element 알고리즘 Linked List의 노드 개수를 구한 다음, 가운데 인덱스의 Node를 찾는 방법입니다. class Solution(object): def middleNode(self, head): node = head size = 0 while(no..
문제 Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target. You may assume that each input would have exactly one solution, and you may not use the same element twice. You can return the answer in any order. 정수 배열 nums와 정수 target이 주어졌을 때, 두 개의 숫자를 더하면 target이 되는 인덱스들을 반환해야한다. 각 입력은 정확히 하나의 해결책을 가지며, 동일한 요소를 두 번 사용하지 않아야 합니다. 답변은 어떤..