목록LeetCode (318)
넘치게 채우기
https://leetcode.com/problems/relative-sort-array/description/leetcode - Relative Sort Array문제 유형 : 정렬, 해시문제 난이도 : Easy 문제Given two arrays arr1 and arr2, the elements of arr2 are distinct, and all elements in arr2 are also in arr1.Sort the elements of arr1 such that the relative ordering of items in arr1 are the same as in arr2. Elements that do not appear in arr2 should be placed at the end of ..
https://leetcode.com/problems/height-checker/description/leetcode - Height Checker문제 유형 : 정렬문제 난이도 : Easy 문제A school is trying to take an annual photo of all the students. The students are asked to stand in a single file line in non-decreasing order by height. Let this ordering be represented by the integer array expected where expected[i] is the expected height of the ith student in line.You ar..
https://leetcode.com/problems/subarray-sums-divisible-by-k/description/leetcode - Subarray Sums Divisible by K문제 유형 : 부분합문제 난이도 : Medium 문제Given an integer array nums and an integer k, return the number of non-empty subarrays that have a sum divisible by k.A subarray is a contiguous part of an array. 정수배열 nums와 정수 k가 주어진다.길이가 1이상이며 합이 k의배수인 부분배열의 개수를 구하시오. 풀이부분합으로 값을 누적해서 풀어주면 된다.https://riverov..
https://leetcode.com/problems/continuous-subarray-sum/description/leetcode - Continuous Subarray Sum문제 유형 : 부분합, 수학문제 난이도 : Medium 문제Given an integer array nums and an integer k, return true if nums has a good subarray or false otherwise.A good subarray is a subarray where:its length is at least two, andthe sum of the elements of the subarray is a multiple of k.Note that:A subarray is a contiguo..
https://leetcode.com/problems/replace-words/description/leetcode - Replace Words문제 유형 : 문자열 처리, 트라이(Trie)문제 난이도 : Medium 문제In English, we have a concept called root, which can be followed by some other word to form another longer word - let's call this word derivative. For example, when the root "help" is followed by the word "ful", we can form a derivative "helpful".Given a dictionary consisti..
https://leetcode.com/problems/hand-of-straights/description/leetcode - Hand of Straights문제 유형 : 우선순위 큐, 그리디, 해시문제 난이도 : Medium 문제Alice has some number of cards and she wants to rearrange the cards into groups so that each group is of size groupSize, and consists of groupSize consecutive cards.Given an integer array hand where hand[i] is the value written on the ith card and an integer groupSize,..
https://leetcode.com/problems/find-common-characters/description/ leetcode - Find Common Characters문제 유형 : 문자열 처리, 구현문제 난이도 : Easy 문제Given a string array words, return an array of all characters that show up in all strings within the words (including duplicates). You may return the answer in any order. 문자열 배열 words가 주어진다. words의 모든 문자들에서 겹치는 문자들을 찾아 반환하시오. 어떤 순서든 상관없습니다. 풀이freq(26,1e9) 배열을 만들어서 ..
https://leetcode.com/problems/longest-palindrome/description/?source=submission-noacleetcode - Longest Palindrome문제 유형 : 문자열 처리문제 난이도 : Easy 문제Given a string s which consists of lowercase or uppercase letters, return the length of the longest palindrome that can be built with those letters.Letters are case sensitive, for example, "Aa" is not considered a palindrome. 문자열 s가 주어집니다. 이들로 만들 수 있는 가장 ..
https://leetcode.com/problems/append-characters-to-string-to-make-subsequence/description/leetcode - Append Characters to String to Make Subsequence문제 유형 : 문자열처리, 그리디문제 난이도 : Medium문제 You are given two strings s and t consisting of only lowercase English letters.Return the minimum number of characters that need to be appended to the end of s so that t becomes a subsequence of s.A subsequence is ..
https://leetcode.com/problems/reverse-string/description/leetcode - Reverse String문제 유형 : 문자열 처리, 투 포인터문제 난이도 : Easy 문제Write a function that reverses a string. The input string is given as an array of characters s.You must do this by modifying the input array in-place with O(1) extra memory. 역문자열로 만드는 함수를 작성하시오. 배열로 주어집니다.O(1)공간복잡도여야 합니다. 풀이left가 right보다 작은동안, swap()해주면 된다.left++right-- 코드C++cla..