본문 바로가기

LeetCode/Two Pointers11

[LeetCode][Kotlin] 557. Reverse Words in a String III 557. Reverse Words in a String IIIGiven a string s, reverse the order of characters in each word within a sentence while still preserving whitespace and initial word order.문자열 s가 주어지면, 공백과 초기 단어 순서를 유지하면서 문장 내 각 단어의 문자 순서를 뒤집습니다. Example 1:Input: s = "Let's take LeetCode contest"Output: "s'teL ekat edoCteeL tsetnoc" Example 2:Input: s = "Mr Ding"Output: "rM gniD" Constraints:1 s contains printab.. 2024. 10. 19.
[LeetCode][Kotlin] 1768. Merge Strings Alternately 1768. Merge Strings AlternatelyYou are given two strings word1 and word2. Merge the strings by adding letters in alternating order, starting with word1. If a string is longer than the other, append the additional letters onto the end of the merged string. Return the merged string.두 개의 문자열 word1과 word2가 주어집니다. word1부터 시작하여 번갈아 가며 문자를 추가하여 문자열을 병합합니다. 문자열이 다른 문자열보다 길면 추가 문자를 병합된 문자열의 끝에 추가합니다. 병합된.. 2024. 10. 19.
[LeetCode][Kotlin] 80. Remove Duplicates from Sorted Array II 80. Remove Duplicates from Sorted Array IIGiven an integer array nums sorted in non-decreasing order, remove some duplicates in-place such that each unique element appears at most twice. The relative order of the elements should be kept the same. Since it is impossible to change the length of the array in some languages, you must instead have the result be placed in the first part of the array n.. 2024. 10. 4.
[LeetCode][Kotlin] 844. Backspace String Compare 844. Backspace String CompareGiven two strings s and t, return true if they are equal when both are typed into empty text editors. '#' means a backspace character. Note that after backspacing an empty text, the text will continue empty.두 개의 문자열 s와 t가 주어졌을 때, 둘 다 빈 텍스트 편집기에 입력했을 때 같으면 true를 반환합니다. '#'은 백스페이스 문자를 의미합니다. 빈 텍스트를 백스페이스한 후에는 텍스트가 계속 비어 있게 됩니다. Example 1:Input: s = "ab#c", t = "ad#c"Ou.. 2024. 10. 1.