본문 바로가기

Algorithm/String

(92)
(C++, Rust) - LeetCode (easy) 944. Delete Columns to Make Sorted https://leetcode.com/problems/delete-columns-to-make-sorted/description/ strs[j+1][i]) { isNotLexicographically = true; break; } } if (isNotLexicographically) columnsToDelete++; } return columnsToDelete; } }; 📔 Rust impl Solution { pub fn min_deletion_size(strs: Vec) -> i32 { let mut columns_to_delete = 0; for i in 0..strs[0].len() { for j in 0..strs.len() - 1 { if strs[j].as_bytes()[i] > strs[j..
(C++) - LeetCode (easy) 929. Unique Email Addresses https://leetcode.com/problems/unique-email-addresses/description/
(C++, Rust) - LeetCode (easy) 917. Reverse Only Letters https://leetcode.com/problems/reverse-only-letters/description/ Reverse Only Letters - LeetCode Can you solve this real interview question? Reverse Only Letters - Given a string s, reverse the string according to the following rules: * All the characters that are not English letters remain in the same position. * All the English letters (lowercase or leetcode.com 문자열을 다루는 문제였습니다. 📕 풀이방법 📔 풀이과정 s..
(C++) - LeetCode (easy) 868. Binary Gap https://leetcode.com/problems/binary-gap/description/ Binary Gap - LeetCode Can you solve this real interview question? Binary Gap - Given a positive integer n, find and return the longest distance between any two adjacent 1's in the binary representation of n. If there are no two adjacent 1's, return 0. Two 1's are adjacent if th leetcode.com 이진법 변환 구현 문제였습니다. 📕 풀이방법 📔 입력 및 초기화 1. 이진법으로 변환해 문자열..
(C++) - LeetCode (easy) 859. Buddy Strings https://leetcode.com/problems/buddy-strings/description/ Buddy Strings - LeetCode Can you solve this real interview question? Buddy Strings - Given two strings s and goal, return true if you can swap two letters in s so the result is equal to goal, otherwise, return false. Swapping letters is defined as taking two indices i and j (0-ind leetcode.com 문자열을 다뤄보는 문제였습니다. 📕 풀이방법 📔 풀이과정 여러 경우의 수가 있습니다..
(C++) - LeetCode (easy) 844. Backspace String Compare https://leetcode.com/problems/backspace-string-compare/description/ Backspace String Compare - LeetCode Can you solve this real interview question? Backspace String Compare - Given 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 tex leetcode.com 문자열 trim하는 구현 문제였습니다. 📕 ..
(C++) - LeetCode (easy) 824. Goat Latin https://leetcode.com/problems/goat-latin/description/ Goat Latin - LeetCode Can you solve this real interview question? Goat Latin - You are given a string sentence that consist of words separated by spaces. Each word consists of lowercase and uppercase letters only. We would like to convert the sentence to "Goat Latin" (a made-up leetcode.com 문자열 다루는 문제였습니다. 📕 풀이방법 📔 입력 및 초기화 1. 공백 문자 ' '를 구분자로..
(C++) - LeetCode (easy) 819. Most Common Word https://leetcode.com/problems/most-common-word/description/ Most Common Word - LeetCode Can you solve this real interview question? Most Common Word - Given a string paragraph and a string array of the banned words banned, return the most frequent word that is not banned. It is guaranteed there is at least one word that is not banned, and tha leetcode.com 구현 문제였습니다. 📕 풀이방법 📔 입력 및 초기화 단어와 빈도수를 저장..