본문 바로가기

Algorithm/String

(134)
(C++) - LeetCode (easy) 1078. Occurrences After Bigram https://leetcode.com/problems/occurrences-after-bigram/description/ Occurrences After Bigram - LeetCode Can you solve this real interview question? Occurrences After Bigram - Given two strings first and second, consider occurrences in some text of the form "first second third", where second comes immediately after first, and third comes immediately after sec leetcode.com 문자열을 다루는 문제였습니다. 📕 풀이방법 ..
(C++) - LeetCode (easy) 1002. Find Common Characters https://leetcode.com/problems/find-common-characters/ LeetCode - The World's Leading Online Programming Learning Platform Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 문자열 다루는 문제였습니다. 📕 풀이방법 📔 입력 및 초기화 1. alphabat별 전체 words의 최소 빈도를 저장할 vector minFreq를 선언 후 각 값을 INT_MAX로 초기화해줍니다. 2. 정답 변수 ..
(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하는 구현 문제였습니다. 📕 ..