[LeetCode] 1910. Remove All Occurrences of a Substring (Python)
·
알고리즘/LeetCode
난이도: Medium문제 설명 Given two strings s and part, perform the following operation on s until all occurrences of the substring part are removed:Find the leftmost occurrence of the substring part and remove it from s.Return s after removing all occurrences of part.A substring is a contiguous sequence of characters in a string. 문제 예제Example 1:Input: s = "daabcbaabcbc", part = "abc"Output: "dab"Explana..
[LeetCode] 3223. Minimum Length of String After Operations (Python)
·
알고리즘/LeetCode
난이도: Medium 문제 설명You are given a string s.You can perform the following process on s any number of times:Choose an index i in the string such that there is at least one character to the left of index i that is equal to s[i], and at least one character to the right that is also equal to s[i].Delete the closest character to the left of index i that is equal to s[i].Delete the closest character to ..
[LeetCode] 916. Word Subsets (Python)
·
알고리즘/LeetCode
난이도: Medium 문제 설명You are given two string arrays words1 and words2.A string b is a subset of string a if every letter in b occurs in a including multiplicity.For example, "wrr" is a subset of "warrior" but is not a subset of "world".A string a from words1 is universal if for every string b in words2, b is a subset of a.Return an array of all the universal strings in words1. You may return the an..
[LeetCode] 2185. Counting Words With a Given Prefix (Python)
·
알고리즘/LeetCode
난이도: Easy 문제 설명You are given an array of strings words and a string pref. Return the number of strings in words that contain pref as a prefix. A prefix of a string s is any leading contiguous substring of s. 문제 예제Example 1:Input: words = ["pay","attention","practice","attend"],pref= "at"Output: 2Explanation: The 2 strings that contain "at" as a prefix are: "attention" and "attend".Example 2:Inpu..
[LeetCode] 3042. Count Prefix and Suffix Pairs I (Python)
·
알고리즘/LeetCode
난이도: Easy 문제 설명You are given a 0-indexed string array words.Let's define a boolean function isPrefixAndSuffix that takes two strings, str1 and str2:isPrefixAndSuffix(str1, str2) returns true if str1 is both a  prefix and a suffix of str2, and false otherwise.For example, isPrefixAndSuffix("aba", "ababa") is true because "aba" is a prefix of "ababa" and also a suffix, but isPrefixAndSuffix("abc",..
[LeetCode] 1408. String Matching in an Array (Python)
·
알고리즘/LeetCode
난이도: Easy 문제 설명Given an array of string words, return all strings in words that is a substring of another word. You can return the answer in any order. A substring is a contiguous sequence of characters within a string 문제 예제Example 1:Input: words = ["mass","as","hero","superhero"] Output: ["as","hero"] Explanation: "as" is substring of "mass" and "hero" is substring of "superhero". ["hero","as"]..