LeetCode/Array & Hashing42 [LeetCode][Kotlin] 68. Text Justification 68. Text JustificationGiven an array of strings words and a width maxWidth, format the text such that each line has exactly maxWidth characters and is fully (left and right) justified. You should pack your words in a greedy approach; that is, pack as many words as you can in each line. Pad extra spaces ' ' when necessary so that each line has exactly maxWidth characters. Extra spaces between wor.. 2024. 9. 23. [LeetCode][Kotlin] 1291. Sequential Digits 1291. Sequential DigitsAn integer has sequential digits if and only if each digit in the number is one more than the previous digit. Return a sorted list of all the integers in the range [low, high] inclusive that have sequential digits.정수는 숫자의 각 숫자가 이전 숫자보다 하나 더 큰 경우에만 연속 숫자를 갖습니다. 연속 숫자가 있는 [낮음, 높음] 범위(포함)의 모든 정수의 정렬된 목록을 반환합니다. Example 1:Input: low = 100, high = 300Output: [123,234] Example 2.. 2024. 9. 5. [LeetCode][Kotlin] 2870. Minimum Number of Operations to Make Array Empty 2870. Minimum Number of Operations to Make Array EmptyYou are given a 0-indexed array nums consisting of positive integers.There are two types of operations that you can apply on the array any number of times:Choose two elements with equal values and delete them from the array.Choose three elements with equal values and delete them from the array.Return the minimum number of operations required .. 2024. 9. 5. [LeetCode][Kotlin] 179. Largest Number 179. Largest NumberGiven a list of non-negative integers nums, arrange them such that they form the largest number and return it.Since the result may be very large, so you need to return a string instead of an integer.음수가 아닌 정수 숫자 목록이 주어지면 가장 큰 숫자를 형성하도록 배열하여 반환합니다. 결과가 매우 클 수 있으므로 정수 대신 문자열을 반환해야 합니다. Example 1:Input: nums = [10,2]Output: "210" Example 2:Input: nums = [3,30,34,5,9]Output: "9534.. 2024. 8. 30. [LeetCode][Kotlin] 28. Find the Index of the First Occurrence in a String 28. Find the Index of the First Occurrence in a StringGiven two strings needle and haystack, return the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.needle과 haystack이라는 두 문자열이 주어지면 haystack에서 needle이 처음 나타나는 인덱스를 반환하거나, needle이 haystack의 일부가 아닌 경우 -1을 반환합니다. Example 1:Input: haystack = "sadbutsad", needle = "sad"Output: 0Explanation: "sad" occurs a.. 2024. 8. 29. [LeetCode][Kotlin] 2002. Maximum Product of the Length of Two Palindromic Subsequences 2002. Maximum Product of the Length of Two Palindromic SubsequencesGiven a string s, find two disjoint palindromic subsequences of s such that the product of their lengths is maximized. The two subsequences are disjoint if they do not both pick a character at the same index. Return the maximum possible product of the lengths of the two palindromic subsequences. A subsequence is a string that can.. 2024. 8. 28. [LeetCode][Kotlin] 1963. Minimum Number of Swaps to Make the String Balanced 1963. Minimum Number of Swaps to Make the String BalancedYou are given a 0-indexed string s of even length n. The string consists of exactly n / 2 opening brackets '[' and n / 2 closing brackets ']'.A string is called balanced if and only if:It is the empty string, orIt can be written as AB, where both A and B are balanced strings, orIt can be written as [C], where C is a balanced string.You may.. 2024. 8. 28. 이전 1 2 3 4 5 6 다음