본문 바로가기

Algorithm101

[프로그래머스] 올바른 괄호 올바른 괄호 https://school.programmers.co.kr/learn/courses/30/lessons/12909?language=cpp 문제 설명 괄호가 바르게 짝지어졌다는 것은 '(' 문자로 열렸으면 반드시 짝지어서 ')' 문자로 닫혀야 한다는 뜻입니다. 예를 들어 "()()" 또는 "(())()" 는 올바른 괄호입니다. ")()(" 또는 "(()(" 는 올바르지 않은 괄호입니다. '(' 또는 ')' 로만 이루어진 문자열 s가 주어졌을 때, 문자열 s가 올바른 괄호이면 true를 return 하고, 올바르지 않은 괄호이면 false를 return 하는 solution 함수를 완성해 주세요. 제한사항 문자열 s의 길이 : 100,000 이하의 자연수 문자열 s는 '(' 또는 ')' 로만 이.. 2023. 5. 1.
[이진 검색] 두 배열의 교집합 349 | Intersection of Two Arrays https://leetcode.com/problems/intersection-of-two-arrays/ 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. Example 1: Input: nums1 = [1,2,2,1], nums2 = [2,2] Output: [2] Example 2: Input: nums1 = [4,9,5], nums2 = [9,4,9,8,4] Output: [9,4] Explanat.. 2023. 4. 6.
[그리디 알고리즘] 쿠키 455 | Assign Cookies https://leetcode.com/problems/assign-cookies/ Assume you are an awesome parent and want to give your children some cookies. But, you should give each child at most one cookie. Each child i has a greed factor g[i], which is the minimum size of a cookie that the child will be content with; and each cookie j has a size s[j]. If s[j] >= g[i], we can assign the cookie j to the ch.. 2023. 4. 6.
[그리디 알고리즘] 주유소 134 | Gas Station https://leetcode.com/problems/gas-station/ There are n gas stations along a circular route, where the amount of gas at the ith station is gas[i]. You have a car with an unlimited gas tank and it costs cost[i] of gas to travel from the ith station to its next (i + 1)th station. You begin the journey with an empty tank at one of the gas stations. Given two integer arrays gas and .. 2023. 4. 5.
[LeetCode] 1523 | Count Odd Numbers in an Interval Range 1523 | Count Odd Numbers in an Interval Range https://leetcode.com/problems/count-odd-numbers-in-an-interval-range/ Given two non-negative integers low and high. Return the count of odd numbers between low and high (inclusive). Example 1: Input: low = 3, high = 7 Output: 3 Explanation: The odd numbers between 3 and 7 are [3,5,7]. Example 2: Input: low = 8, high = 10 Output: 1 Explanation: The od.. 2023. 4. 3.
[LeetCode] 300 | Longest Increasing Subsequence 300 | Longest Increasing Subsequence https://leetcode.com/problems/longest-increasing-subsequence/ Given an integer array nums, return the length of the longest strictly increasing subsequence. Example 1: Input: nums = [10,9,2,5,3,7,101,18] Output: 4 Explanation: The longest increasing subsequence is [2,3,7,101], therefore the length is 4. Example 2: Input: nums = [0,1,0,3,2,3] Output: 4 Example.. 2023. 3. 31.
반응형