String Problems
Master string problems with AI-powered solutions. Get instant coding assistance during your technical interviews for all 548 problems in this category.
Total Problems: 548
Easy: 173
Medium: 258
Hard: 117
Showing 50 of 548 problems
Problems
Scroll within this area to browse all problems
#
Title
Difficulty
String LeetCode Problems List
- 412. Fizz Buzz - Easy - StringGiven an integer n, return a string array answer (1-indexed) where: answer[i] == "FizzBuzz" if i is divisible by 3 and 5. answer[i] == "Fizz" if i is ... Topics: Math, String, Simulation
- 3. Longest Substring Without Repeating Characters - Medium - StringGiven a string s, find the length of the longest substring without duplicate characters.... Topics: Hash Table, String, Sliding Window
- 5. Longest Palindromic Substring - Medium - StringGiven a string s, return the longest palindromic substring in s.... Topics: Two Pointers, String, Dynamic Programming
- 127. Word Ladder - Hard - StringA transformation sequence from word beginWord to word endWord using a dictionary wordList is a sequence of words beginWord -> s1 -> s2 -> ... -> sk su... Topics: Hash Table, String, Breadth-First Search
- 1250. Longest Common Subsequence - Medium - StringGiven two strings text1 and text2, return the length of their longest common subsequence. If there is no common subsequence, return 0. A subsequence o... Topics: String, Dynamic Programming
- 49. Group Anagrams - Medium - StringGiven an array of strings strs, group the anagrams together. You can return the answer in any order.... Topics: Array, Hash Table, String, Sorting
- 76. Minimum Window Substring - Hard - StringGiven two strings s and t of lengths m and n respectively, return the minimum window substring of s such that every character in t (including duplicat... Topics: Hash Table, String, Sliding Window
- 79. Word Search - Medium - StringGiven an m x n grid of characters board and a string word, return true if word exists in the grid. The word can be constructed from letters of sequent... Topics: Array, String, Backtracking, Depth-First Search, Matrix
- 344. Reverse String - Easy - StringWrite a function that reverses a string. The input string is given as an array of characters s. You must do this by modifying the input array in-place... Topics: Two Pointers, String
- 409. Longest Palindrome - Easy - StringGiven a string s which consists of lowercase or uppercase letters, return the length of the longest palindrome that can be built with those letters. L... Topics: Hash Table, String, Greedy
- 20. Valid Parentheses - Easy - StringGiven a string s containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. An input string is valid if: ... Topics: String, Stack
- 721. Accounts Merge - Medium - StringGiven a list of accounts where each element accounts[i] is a list of strings, where the first element accounts[i][0] is a name, and the rest of the el... Topics: Array, Hash Table, String, Depth-First Search, Breadth-First Search, Union Find, Sorting
- 14. Longest Common Prefix - Easy - StringWrite a function to find the longest common prefix string amongst an array of strings. If there is no common prefix, return an empty string "".... Topics: Array, String, Trie
- 151. Reverse Words in a String - Medium - StringGiven an input string s, reverse the order of the words. A word is defined as a sequence of non-space characters. The words in s will be separated by ... Topics: Two Pointers, String
- 125. Valid Palindrome - Easy - StringA phrase is a palindrome if, after converting all uppercase letters into lowercase letters and removing all non-alphanumeric characters, it reads the ... Topics: Two Pointers, String
- 516. Longest Palindromic Subsequence - Medium - StringGiven a string s, find the longest palindromic subsequence's length in s. A subsequence is a sequence that can be derived from another sequence by del... Topics: String, Dynamic Programming
- 72. Edit Distance - Medium - StringGiven two strings word1 and word2, return the minimum number of operations required to convert word1 to word2. You have the following three operations... Topics: String, Dynamic Programming
- 179. Largest Number - Medium - StringGiven 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 ... Topics: Array, String, Greedy, Sorting
- 468. Validate IP Address - Medium - StringGiven a string queryIP, return "IPv4" if IP is a valid IPv4 address, "IPv6" if IP is a valid IPv6 address or "Neither" if IP is not a correct IP of an... Topics: String
- 17. Letter Combinations of a Phone Number - Medium - StringGiven a string containing digits from 2-9 inclusive, return all possible letter combinations that the number could represent. Return the answer in any... Topics: Hash Table, String, Backtracking
- 208. Implement Trie (Prefix Tree) - Medium - StringA trie (pronounced as "try") or prefix tree is a tree data structure used to efficiently store and retrieve keys in a dataset of strings. There are va... Topics: Hash Table, String, Design, Trie
- 8. String to Integer (atoi) - Medium - StringImplement the myAtoi(string s) function, which converts a string to a 32-bit signed integer. The algorithm for myAtoi(string s) is as follows: Whitesp... Topics: String
- 383. Ransom Note - Easy - StringGiven two strings ransomNote and magazine, return true if ransomNote can be constructed by using the letters from magazine and false otherwise. Each l... Topics: Hash Table, String, Counting
- 67. Add Binary - Easy - StringGiven two binary strings a and b, return their sum as a binary string.... Topics: Math, String, Bit Manipulation, Simulation
- 91. Decode Ways - Medium - StringYou have intercepted a secret message encoded as a string of numbers. The message is decoded via the following mapping: "1" -> 'A' "2" -> 'B' ... "25"... Topics: String, Dynamic Programming
- 242. Valid Anagram - Easy - StringGiven two strings s and t, return true if t is an anagram of s, and false otherwise.... Topics: Hash Table, String, Sorting
- 224. Basic Calculator - Hard - StringGiven a string s representing a valid expression, implement a basic calculator to evaluate it, and return the result of the evaluation. Note: You are ... Topics: Math, String, Stack, Recursion
- 65. Valid Number - Hard - StringGiven a string s, return whether s is a valid number. For example, all the following are valid numbers: "2", "0089", "-0.1", "+3.14", "4.", "-.9", "2e... Topics: String
- 2373. Apply Discount to Prices - Medium - StringA sentence is a string of single-space separated words where each word can contain digits, lowercase letters, and the dollar sign '$'. A word represen... Topics: String
- 212. Word Search II - Hard - StringGiven an m x n board of characters and a list of strings words, return all words on the board. Each word must be constructed from letters of sequentia... Topics: Array, String, Backtracking, Trie, Matrix
- 2406. Decode the Message - Easy - StringYou are given the strings key and message, which represent a cipher key and a secret message, respectively. The steps to decode message are as follows... Topics: Hash Table, String
- 567. Permutation in String - Medium - StringGiven two strings s1 and s2, return true if s2 contains a permutation of s1, or false otherwise. In other words, return true if one of s1's permutatio... Topics: Hash Table, Two Pointers, String, Sliding Window
- 22. Generate Parentheses - Medium - StringGiven n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.... Topics: String, Dynamic Programming, Backtracking
- 13. Roman to Integer - Easy - StringRoman numerals are represented by seven different symbols: I, V, X, L, C, D and M. Symbol Value I 1 V 5 X 10... Topics: Hash Table, Math, String
- 6. Zigzag Conversion - Medium - StringThe string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font ... Topics: String
- 227. Basic Calculator II - Medium - StringGiven a string s which represents an expression, evaluate this expression and return its value. The integer division should truncate toward zero. You ... Topics: Math, String, Stack
- 297. Serialize and Deserialize Binary Tree - Hard - StringSerialization is the process of converting a data structure or object into a sequence of bits so that it can be stored in a file or memory buffer, or ... Topics: String, Tree, Depth-First Search, Breadth-First Search, Design, Binary Tree
- 43. Multiply Strings - Medium - StringGiven two non-negative integers num1 and num2 represented as strings, return the product of num1 and num2, also represented as a string. Note: You mus... Topics: Math, String, Simulation
- 68. Text Justification - Hard - StringGiven 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... Topics: Array, String, Simulation
- 438. Find All Anagrams in a String - Medium - StringGiven two strings s and p, return an array of all the start indices of p's anagrams in s. You may return the answer in any order.... Topics: Hash Table, String, Sliding Window
- 965. Unique Email Addresses - Easy - StringEvery valid email consists of a local name and a domain name, separated by the '@' sign. Besides lowercase letters, the email may contain one or more ... Topics: Array, Hash Table, String
- 720. Longest Word in Dictionary - Medium - StringGiven an array of strings words representing an English Dictionary, return the longest word in words that can be built one character at a time by othe... Topics: Array, Hash Table, String, Trie, Sorting
- 3934. Coupon Code Validator - Easy - StringYou are given three arrays of length n that describe the properties of n coupons: code, businessLine, and isActive. The ith coupon has: code[i]: a str... Topics: Array, Hash Table, String, Sorting
- 424. Longest Repeating Character Replacement - Medium - StringYou are given a string s and an integer k. You can choose any character of the string and change it to any other uppercase English character. You can ... Topics: Hash Table, String, Sliding Window
- 394. Decode String - Medium - StringGiven an encoded string, return its decoded string. The encoding rule is: k[encoded_string], where the encoded_string inside the square brackets is be... Topics: String, Stack, Recursion
- 387. First Unique Character in a String - Easy - StringGiven a string s, find the first non-repeating character in it and return its index. If it does not exist, return -1.... Topics: Hash Table, String, Queue, Counting
- 71. Simplify Path - Medium - StringYou are given an absolute path for a Unix-style file system, which always begins with a slash '/'. Your task is to transform this absolute path into i... Topics: String, Stack
- 301. Remove Invalid Parentheses - Hard - StringGiven a string s that contains parentheses and letters, remove the minimum number of invalid parentheses to make the input string valid. Return a list... Topics: String, Backtracking, Breadth-First Search
- 822. Unique Morse Code Words - Easy - StringInternational Morse Code defines a standard encoding where each letter is mapped to a series of dots and dashes, as follows: 'a' maps to ".-", 'b' map... Topics: Array, Hash Table, String
- 12. Integer to Roman - Medium - StringSeven different symbols represent Roman numerals with the following values: Symbol Value I 1 V 5 X 10 L 50 C 100 D 500 M 1000 Roman numerals are forme... Topics: Hash Table, Math, String
- 32. Longest Valid Parentheses - Hard - StringGiven a string containing just the characters '(' and ')', return the length of the longest valid (well-formed) parentheses substring.... Topics: String, Dynamic Programming, Stack
- 753. Open the Lock - Medium - StringYou have a lock in front of you with 4 circular wheels. Each wheel has 10 slots: '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'. The wheels can rota... Topics: Array, Hash Table, String, Breadth-First Search
- 139. Word Break - Medium - StringGiven a string s and a dictionary of strings wordDict, return true if s can be segmented into a space-separated sequence of one or more dictionary wor... Topics: Array, Hash Table, String, Dynamic Programming, Trie, Memoization
- 336. Palindrome Pairs - Hard - StringYou are given a 0-indexed array of unique strings words. A palindrome pair is a pair of integers (i, j) such that: 0 <= i, j < words.length, i != j, a... Topics: Array, Hash Table, String, Trie
- 1960. Check if the Sentence Is Pangram - Easy - StringA pangram is a sentence where every letter of the English alphabet appears at least once. Given a string sentence containing only lowercase English le... Topics: Hash Table, String
- 443. String Compression - Medium - StringGiven an array of characters chars, compress it using the following algorithm: Begin with an empty string s. For each group of consecutive repeating c... Topics: Two Pointers, String
- 10. Regular Expression Matching - Hard - StringGiven an input string s and a pattern p, implement regular expression matching with support for '.' and '*' where: '.' Matches any single character.... Topics: String, Dynamic Programming, Recursion
- 3613. Maximize Amount After Two Days of Conversions - Medium - StringYou are given a string initialCurrency, and you start with 1.0 of initialCurrency. You are also given four arrays with currency pairs (strings) and ra... Topics: Array, String, Depth-First Search, Breadth-First Search, Graph
- 647. Palindromic Substrings - Medium - StringGiven a string s, return the number of palindromic substrings in it. A string is a palindrome when it reads the same backward as forward. A substring ... Topics: Two Pointers, String, Dynamic Programming
- 126. Word Ladder II - Hard - StringA transformation sequence from word beginWord to word endWord using a dictionary wordList is a sequence of words beginWord -> s1 -> s2 -> ... -> sk su... Topics: Hash Table, String, Backtracking, Breadth-First Search
- 171. Excel Sheet Column Number - Easy - StringGiven a string columnTitle that represents the column title as appears in an Excel sheet, return its corresponding column number. For example: A -> 1 ... Topics: Math, String
- 680. Valid Palindrome II - Easy - StringGiven a string s, return true if the s can be palindrome after deleting at most one character from it.... Topics: Two Pointers, String, Greedy
- 2021. Remove All Occurrences of a Substring - Medium - StringGiven two strings s and part, perform the following operation on s until all occurrences of the substring part are removed: Find the leftmost occurren... Topics: String, Stack, Simulation
- 952. Word Subsets - Medium - StringYou 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 exa... Topics: Array, Hash Table, String
- 131. Palindrome Partitioning - Medium - StringGiven a string s, partition s such that every substring of the partition is a palindrome. Return all possible palindrome partitioning of s.... Topics: String, Dynamic Programming, Backtracking
- 97. Interleaving String - Medium - StringGiven strings s1, s2, and s3, find whether s3 is formed by an interleaving of s1 and s2. An interleaving of two strings s and t is a configuration whe... Topics: String, Dynamic Programming
- 290. Word Pattern - Easy - StringGiven a pattern and a string s, find if s follows the same pattern. Here follow means a full match, such that there is a bijection between a letter in... Topics: Hash Table, String
- 433. Minimum Genetic Mutation - Medium - StringA gene string can be represented by an 8-character long string, with choices from 'A', 'C', 'G', and 'T'. Suppose we need to investigate a mutation fr... Topics: Hash Table, String, Breadth-First Search
- 28. Find the Index of the First Occurrence in a String - Easy - 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.... Topics: Two Pointers, String, String Matching
- 205. Isomorphic Strings - Easy - StringGiven two strings s and t, determine if they are isomorphic. Two strings s and t are isomorphic if the characters in s can be replaced to get t. All o... Topics: Hash Table, String
- 3267. Find Longest Special Substring That Occurs Thrice I - Medium - StringYou are given a string s that consists of lowercase English letters. A string is called special if it is made up of only a single character. For examp... Topics: Hash Table, String, Binary Search, Sliding Window, Counting
- 1119. Robot Bounded In Circle - Medium - StringOn an infinite plane, a robot initially stands at (0, 0) and faces north. Note that: The north direction is the positive direction of the y-axis. The ... Topics: Math, String, Simulation
- 920. Uncommon Words from Two Sentences - Easy - StringA sentence is a string of single-space separated words where each word consists only of lowercase letters. A word is uncommon if it appears exactly on... Topics: Hash Table, String, Counting
- 2550. Words Within Two Edits of Dictionary - Medium - StringYou are given two string arrays, queries and dictionary. All words in each array comprise of lowercase English letters and have the same length. In on... Topics: Array, String, Trie
- 990. Verifying an Alien Dictionary - Easy - StringIn an alien language, surprisingly, they also use English lowercase letters, but possibly in a different order. The order of the alphabet is some perm... Topics: Array, Hash Table, String
- 837. Most Common Word - Easy - StringGiven 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... Topics: Array, Hash Table, String, Counting
- 420. Strong Password Checker - Hard - StringA password is considered strong if the below conditions are all met: It has at least 6 characters and at most 20 characters. It contains at least one ... Topics: String, Greedy, Heap (Priority Queue)
- 399. Evaluate Division - Medium - StringYou are given an array of variable pairs equations and an array of real numbers values, where equations[i] = [Ai, Bi] and values[i] represent the equa... Topics: Array, String, Depth-First Search, Breadth-First Search, Union Find, Graph, Shortest Path
- 557. Reverse Words in a String III - Easy - StringGiven a string s, reverse the order of characters in each word within a sentence while still preserving whitespace and initial word order.... Topics: Two Pointers, String
- 434. Number of Segments in a String - Easy - StringGiven a string s, return the number of segments in the string. A segment is defined to be a contiguous sequence of non-space characters.... Topics: String
- 726. Number of Atoms - Hard - StringGiven a string formula representing a chemical formula, return the count of each atom. The atomic element always starts with an uppercase character, t... Topics: Hash Table, String, Stack, Sorting
- 640. Solve the Equation - Medium - StringSolve a given equation and return the value of 'x' in the form of a string "x=#value". The equation contains only '+', '-' operation, the variable 'x'... Topics: Math, String, Simulation
- 140. Word Break II - Hard - StringGiven a string s and a dictionary of strings wordDict, add spaces in s to construct a sentence where each word is a valid dictionary word. Return all ... Topics: Array, Hash Table, String, Dynamic Programming, Backtracking, Trie, Memoization
- 211. Design Add and Search Words Data Structure - Medium - StringDesign a data structure that supports adding new words and finding if a string matches any previously added string. Implement the WordDictionary class... Topics: String, Depth-First Search, Design, Trie
- 1274. Number of Days Between Two Dates - Easy - StringWrite a program to count the number of days between two dates. The two dates are given as strings, their format is YYYY-MM-DD as shown in the examples... Topics: Math, String
- 299. Bulls and Cows - Medium - StringYou are playing the Bulls and Cows game with your friend. You write down a secret number and ask your friend to guess what the number is. When your fr... Topics: Hash Table, String, Counting
- 2444. Longest Ideal Subsequence - Medium - StringYou are given a string s consisting of lowercase letters and an integer k. We call a string t ideal if the following conditions are satisfied: t is a ... Topics: Hash Table, String, Dynamic Programming
- 395. Longest Substring with At Least K Repeating Characters - Medium - StringGiven a string s and an integer k, return the length of the longest substring of s such that the frequency of each character in this substring is grea... Topics: Hash Table, String, Divide and Conquer, Sliding Window
- 1128. Remove All Adjacent Duplicates In String - Easy - StringYou are given a string s consisting of lowercase English letters. A duplicate removal consists of choosing two adjacent and equal letters and removing... Topics: String, Stack
- 1205. Defanging an IP Address - Easy - StringGiven a valid (IPv4) IP address, return a defanged version of that IP address. A defanged IP address replaces every period "." with "[.]".... Topics: String
- 1044. Find Common Characters - Easy - StringGiven a string array words, return an array of all characters that show up in all strings within the words (including duplicates). You may return the ... Topics: Array, Hash Table, String
- 3573. Count Substrings That Can Be Rearranged to Contain a String I - Medium - StringYou are given two strings word1 and word2. A string x is called valid if x can be rearranged to have word2 as a prefix. Return the total number of val... Topics: Hash Table, String, Sliding Window
- 132. Palindrome Partitioning II - Hard - StringGiven a string s, partition s such that every substring of the partition is a palindrome. Return the minimum cuts needed for a palindrome partitioning... Topics: String, Dynamic Programming
- 241. Different Ways to Add Parentheses - Medium - StringGiven a string expression of numbers and operators, return all possible results from computing all the different possible ways to group numbers and op... Topics: Math, String, Dynamic Programming, Recursion, Memoization
- 1944. Truncate Sentence - Easy - StringA sentence is a list of words that are separated by a single space with no leading or trailing spaces. Each of the words consists of only uppercase an... Topics: Array, String
- 93. Restore IP Addresses - Medium - StringA valid IP address consists of exactly four integers separated by single dots. Each integer is between 0 and 255 (inclusive) and cannot have leading z... Topics: String, Backtracking
- 451. Sort Characters By Frequency - Medium - StringGiven a string s, sort it in decreasing order based on the frequency of the characters. The frequency of a character is the number of times it appears... Topics: Hash Table, String, Sorting, Heap (Priority Queue), Bucket Sort, Counting
- 807. Custom Sort String - Medium - StringYou are given two strings order and s. All the characters of order are unique and were sorted in some custom order previously. Permute the characters ... Topics: Hash Table, String, Sorting
- 44. Wildcard Matching - Hard - StringGiven an input string (s) and a pattern (p), implement wildcard pattern matching with support for '?' and '*' where: '?' Matches any single character.... Topics: String, Dynamic Programming, Greedy, Recursion
- 316. Remove Duplicate Letters - Medium - StringGiven a string s, remove duplicate letters so that every letter appears once and only once. You must make sure your result is the smallest in lexicogr... Topics: String, Stack, Greedy, Monotonic Stack
- 2378. Sender With Largest Word Count - Medium - StringYou have a chat log of n messages. You are given two string arrays messages and senders where messages[i] is a message sent by senders[i]. A message i... Topics: Array, Hash Table, String, Counting
- 678. Valid Parenthesis String - Medium - StringGiven a string s containing only three types of characters: '(', ')' and '*', return true if s is valid. The following rules define a valid string: An... Topics: String, Dynamic Programming, Stack, Greedy
- 2599. Take K of Each Character From Left and Right - Medium - StringYou are given a string s consisting of the characters 'a', 'b', and 'c' and a non-negative integer k. Each minute, you may take either the leftmost ch... Topics: Hash Table, String, Sliding Window
- 1272. Invalid Transactions - Medium - StringA transaction is possibly invalid if: the amount exceeds $1000, or; if it occurs within (and including) 60 minutes of another transaction with the sam... Topics: Array, Hash Table, String, Sorting
- 591. Tag Validator - Hard - StringGiven a string representing a code snippet, implement a tag validator to parse the code and return whether it is valid. A code snippet is valid if all... Topics: String, Stack
- 1197. Parsing A Boolean Expression - Hard - StringA boolean expression is an expression that evaluates to either true or false. It can be in one of the following shapes: 't' that evaluates to true. 'f... Topics: String, Stack, Recursion
- 1460. Number of Substrings Containing All Three Characters - Medium - StringGiven a string s consisting only of characters a, b and c. Return the number of substrings containing at least one occurrence of all these characters ... Topics: Hash Table, String, Sliding Window
- 1561. Rearrange Words in a Sentence - Medium - StringGiven a sentence text (A sentence is a string of space-separated words) in the following format: First letter is in upper case. Each word in text are ... Topics: String, Sorting
- 2001. Jump Game VII - Medium - StringYou are given a 0-indexed binary string s and two integers minJump and maxJump. In the beginning, you are standing at index 0, which is equal to '0'. ... Topics: String, Dynamic Programming, Sliding Window, Prefix Sum
- 782. Jewels and Stones - Easy - StringYou're given strings jewels representing the types of stones that are jewels, and stones representing the stones you have. Each character in stones is... Topics: Hash Table, String
- 165. Compare Version Numbers - Medium - StringGiven two version strings, version1 and version2, compare them. A version string consists of revisions separated by dots '.'. The value of the revisio... Topics: Two Pointers, String
- 541. Reverse String II - Easy - StringGiven a string s and an integer k, reverse the first k characters for every 2k characters counting from the start of the string. If there are fewer th... Topics: Two Pointers, String
- 1023. Time Based Key-Value Store - Medium - StringDesign a time-based key-value data structure that can store multiple values for the same key at different time stamps and retrieve the key's value at ... Topics: Hash Table, String, Binary Search, Design
- 3329. Find the Length of the Longest Common Prefix - Medium - StringYou are given two arrays with positive integers arr1 and arr2. A prefix of a positive integer is an integer formed by one or more of its digits, start... Topics: Array, Hash Table, String, Trie
- 2502. Sort the People - Easy - StringYou are given an array of strings names, and an array heights that consists of distinct positive integers. Both arrays are of length n. For each index... Topics: Array, Hash Table, String, Sorting
- 768. Partition Labels - Medium - StringYou are given a string s. We want to partition the string into as many parts as possible so that each letter appears in at most one part. For example,... Topics: Hash Table, Two Pointers, String, Greedy
- 1781. Check If Two String Arrays are Equivalent - Easy - StringGiven two string arrays word1 and word2, return true if the two arrays represent the same string, and false otherwise. A string is represented by an a... Topics: Array, String
- 742. To Lower Case - Easy - StringGiven a string s, return the string after replacing every uppercase letter with the same lowercase letter.... Topics: String
- 392. Is Subsequence - Easy - StringGiven two strings s and t, return true if s is a subsequence of t, or false otherwise. A subsequence of a string is a new string that is formed from t... Topics: Two Pointers, String, Dynamic Programming
- 800. Letter Case Permutation - Medium - StringGiven a string s, you can transform every letter individually to be lowercase or uppercase to create another string. Return a list of all possible str... Topics: String, Backtracking, Bit Manipulation
- 873. Guess the Word - Hard - StringYou are given an array of unique strings words where words[i] is six letters long. One word of words was chosen as a secret word. You are also given t... Topics: Array, Math, String, Interactive, Game Theory
- 874. Backspace String Compare - Easy - StringGiven 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... Topics: Two Pointers, String, Stack, Simulation
- 405. Convert a Number to Hexadecimal - Easy - StringGiven a 32-bit integer num, return a string representing its hexadecimal representation. For negative integers, two’s complement method is used. All t... Topics: Math, String, Bit Manipulation
- 3376. Longest Common Suffix Queries - Hard - StringYou are given two arrays of strings wordsContainer and wordsQuery. For each wordsQuery[i], you need to find a string from wordsContainer that has the ... Topics: Array, String, Trie
- 2186. Count Vowel Substrings of a String - Easy - StringA substring is a contiguous (non-empty) sequence of characters within a string. A vowel substring is a substring that only consists of vowels ('a', 'e... Topics: Hash Table, String
- 592. Fraction Addition and Subtraction - Medium - StringGiven a string expression representing an expression of fraction addition and subtraction, return the calculation result in string format. The final r... Topics: Math, String, Simulation
- 1170. Shortest Common Supersequence - Hard - StringGiven two strings str1 and str2, return the shortest string that has both str1 and str2 as subsequences. If there are multiple valid strings, return a... Topics: String, Dynamic Programming
- 1353. Find Resultant Array After Removing Anagrams - Easy - StringYou are given a 0-indexed string array words, where words[i] consists of lowercase English letters. In one operation, select any index i such that 0 <... Topics: Array, Hash Table, String, Sorting
- 2605. Count Anagrams - Hard - StringYou are given a string s containing one or more words. Every consecutive pair of words is separated by a single space ' '. A string t is an anagram of... Topics: Hash Table, Math, String, Combinatorics, Counting
- 389. Find the Difference - Easy - StringYou are given two strings s and t. String t is generated by random shuffling string s and then add one more letter at a random position. Return the le... Topics: Hash Table, String, Bit Manipulation, Sorting
- 583. Delete Operation for Two Strings - Medium - StringGiven two strings word1 and word2, return the minimum number of steps required to make word1 and word2 the same. In one step, you can delete exactly o... Topics: String, Dynamic Programming
- 504. Base 7 - Easy - StringGiven an integer num, return a string of its base 7 representation.... Topics: Math, String
- 3684. Substring Matching Pattern - Easy - StringYou are given a string s and a pattern string p, where p contains exactly one '*' character. The '*' in p can be replaced with any sequence of zero or... Topics: String, String Matching
- 1397. Search Suggestions System - Medium - StringYou are given an array of strings products and a string searchWord. Design a system that suggests at most three product names from products after each... Topics: Array, String, Binary Search, Trie, Sorting, Heap (Priority Queue)
- 2032. Largest Odd Number in String - Easy - StringYou are given a string num, representing a large integer. Return the largest-valued odd integer (as a string) that is a non-empty substring of num, or... Topics: Math, String, Greedy
- 2391. Strong Password Checker II - Easy - StringA password is said to be strong if it satisfies all the following criteria: It has at least 8 characters. It contains at least one lowercase letter. I... Topics: String
- 2113. Find the Kth Largest Integer in the Array - Medium - StringYou are given an array of strings nums and an integer k. Each string in nums represents an integer without leading zeros. Return the string that repre... Topics: Array, String, Divide and Conquer, Sorting, Heap (Priority Queue), Quickselect
- 1567. Maximum Number of Vowels in a Substring of Given Length - Medium - StringGiven a string s and an integer k, return the maximum number of vowel letters in any substring of s with length k. Vowel letters in English are 'a', '... Topics: String, Sliding Window
- 1146. Greatest Common Divisor of Strings - Easy - StringFor two strings s and t, we say "t divides s" if and only if s = t + t + t + ... + t + t (i.e., t is concatenated with itself one or more times). Give... Topics: Math, String
- 1078. Remove Outermost Parentheses - Easy - StringA valid parentheses string is either empty "", "(" + A + ")", or A + B, where A and B are valid parentheses strings, and + represents string concatena... Topics: String, Stack
- 1320. Remove All Adjacent Duplicates in String II - Medium - StringYou are given a string s and an integer k, a k duplicate removal consists of choosing k adjacent and equal letters from s and removing them, causing t... Topics: String, Stack
- 2235. Capitalize the Title - Easy - StringYou are given a string title consisting of one or more words separated by a single space, where each word consists of English letters. Capitalize the ... Topics: String
- 214. Shortest Palindrome - Hard - StringYou are given a string s. You can convert s to a palindrome by adding characters in front of it. Return the shortest palindrome you can find by perfor... Topics: String, Rolling Hash, String Matching, Hash Function
- 415. Add Strings - Easy - StringGiven two non-negative integers, num1 and num2 represented as string, return the sum of num1 and num2 as a string. You must solve the problem without ... Topics: Math, String, Simulation
- 551. Student Attendance Record I - Easy - StringYou are given a string s representing an attendance record for a student where each character signifies whether the student was absent, late, or prese... Topics: String
- 1188. Brace Expansion II - Hard - StringUnder the grammar given below, strings can represent a set of lowercase words. Let R(expr) denote the set of words the expression represents. The gram... Topics: String, Backtracking, Stack, Breadth-First Search
- 58. Length of Last Word - Easy - StringGiven a string s consisting of words and spaces, return the length of the last word in the string. A word is a maximal substring consisting of non-spa... Topics: String
- 1129. Longest String Chain - Medium - StringYou are given an array of words where each word consists of lowercase English letters. wordA is a predecessor of wordB if and only if we can insert ex... Topics: Array, Hash Table, Two Pointers, String, Dynamic Programming, Sorting
- 38. Count and Say - Medium - StringThe count-and-say sequence is a sequence of digit strings defined by the recursive formula: countAndSay(1) = "1" countAndSay(n) is the run-length enco... Topics: String
- 953. Reverse Only Letters - Easy - StringGiven a string s, reverse the string according to the following rules: All the characters that are not English letters remain in the same position. Al... Topics: Two Pointers, String
- 1508. Longest Happy Prefix - Hard - StringA string is called a happy prefix if is a non-empty prefix which is also a suffix (excluding itself). Given a string s, return the longest happy prefi... Topics: String, Rolling Hash, String Matching, Hash Function
- 474. Ones and Zeroes - Medium - StringYou are given an array of binary strings strs and two integers m and n. Return the size of the largest subset of strs such that there are at most m 0'... Topics: Array, String, Dynamic Programming
- 168. Excel Sheet Column Title - Easy - StringGiven an integer columnNumber, return its corresponding column title as it appears in an Excel sheet. For example: A -> 1 B -> 2 C -> 3 ... Z -> 26 AA... Topics: Math, String
- 2364. Longest Path With Different Adjacent Characters - Hard - StringYou are given a tree (i.e. a connected, undirected graph that has no cycles) rooted at node 0 consisting of n nodes numbered from 0 to n - 1. The tree... Topics: Array, String, Tree, Depth-First Search, Graph, Topological Sort
- 746. Prefix and Suffix Search - Hard - StringDesign a special dictionary that searches the words in it by a prefix and a suffix. Implement the WordFilter class: WordFilter(string[] words) Initial... Topics: Array, Hash Table, String, Design, Trie
- 1304. Longest Happy String - Medium - StringA string s is called happy if it satisfies the following conditions: s only contains the letters 'a', 'b', and 'c'. s does not contain any of "aaa", "... Topics: String, Greedy, Heap (Priority Queue)
- 115. Distinct Subsequences - Hard - StringGiven two strings s and t, return the number of distinct subsequences of s which equals t. The test cases are generated so that the answer fits on a 3... Topics: String, Dynamic Programming
- 691. Stickers to Spell Word - Hard - StringWe are given n different types of stickers. Each sticker has a lowercase English word on it. You would like to spell out the given string target by cu... Topics: Array, Hash Table, String, Dynamic Programming, Backtracking, Bit Manipulation, Memoization, Bitmask
- 520. Detect Capital - Easy - StringWe define the usage of capitals in a word to be right when one of the following cases holds: All letters in this word are capitals, like "USA". All le... Topics: String
- 1058. Lexicographically Smallest Equivalent String - Medium - StringYou are given two strings of the same length s1 and s2 and a string baseStr. We say s1[i] and s2[i] are equivalent characters. For example, if s1 = "a... Topics: String, Union Find
- 1970. Sorting the Sentence - Easy - StringA sentence is a list of words that are separated by a single space with no leading or trailing spaces. Each word consists of lowercase and uppercase E... Topics: String, Sorting
- 273. Integer to English Words - Hard - StringConvert a non-negative integer num to its English words representation.... Topics: Math, String, Recursion
- 1371. Minimum Remove to Make Valid Parentheses - Medium - StringGiven a string s of '(' , ')' and lowercase English characters. Your task is to remove the minimum number of parentheses ( '(' or ')', in any position... Topics: String, Stack
- 781. Basic Calculator IV - Hard - StringGiven an expression such as expression = "e + 8 - a + 5" and an evaluation map such as {"e": 1} (given in terms of evalvars = ["e"] and evalints = [1]... Topics: Hash Table, Math, String, Stack, Recursion
- 535. Encode and Decode TinyURL - Medium - StringNote: This is a companion problem to the System Design problem: Design TinyURL. TinyURL is a URL shortening service where you enter a URL such as http... Topics: Hash Table, String, Design, Hash Function
- 3194. Find Words Containing Character - Easy - StringYou are given a 0-indexed array of strings words and a character x. Return an array of indices representing the words that contain the character x. No... Topics: Array, String
- 1238. Alphabet Board Path - Medium - StringOn an alphabet board, we start at position (0, 0), corresponding to character board[0][0]. Here, board = ["abcde", "fghij", "klmno", "pqrst", "uvwxy",... Topics: Hash Table, String
- 639. Decode Ways II - Hard - StringA message containing letters from A-Z can be encoded into numbers using the following mapping: 'A' -> "1" 'B' -> "2" ... 'Z' -> "26" To decode an enco... Topics: String, Dynamic Programming
- 722. Remove Comments - Medium - StringGiven a C++ program, remove comments from it. The program source is an array of strings source where source[i] is the ith line of the source code. Thi... Topics: Array, String
- 957. Minimum Add to Make Parentheses Valid - Medium - StringA parentheses string is valid if and only if: It is the empty string, It can be written as AB (A concatenated with B), where A and B are valid strings... Topics: String, Stack, Greedy
- 686. Repeated String Match - Medium - StringGiven two strings a and b, return the minimum number of times you should repeat string a so that string b is a substring of it. If it is impossible fo... Topics: String, String Matching
- 87. Scramble String - Hard - StringWe can scramble a string s to get a string t using the following algorithm: If the length of the string is 1, stop. If the length of the string is > 1... Topics: String, Dynamic Programming
- 3797. Design Spreadsheet - Medium - StringA spreadsheet is a grid with 26 columns (labeled from 'A' to 'Z') and a given number of rows. Each cell in the spreadsheet can hold an integer value b... Topics: Array, Hash Table, String, Design, Matrix
- 2165. Plates Between Candles - Medium - StringThere is a long table with a line of plates and candles arranged on top of it. You are given a 0-indexed string s consisting of characters '*' and '|'... Topics: Array, String, Binary Search, Prefix Sum
- 763. Special Binary String - Hard - StringSpecial binary strings are binary strings with the following two properties: The number of 0's is equal to the number of 1's. Every prefix of the bina... Topics: String, Recursion
- 1547. Destination City - Easy - StringYou are given the array paths, where paths[i] = [cityAi, cityBi] means there exists a direct path going from cityAi to cityBi. Return the destination ... Topics: Array, Hash Table, String
- 696. Count Binary Substrings - Easy - StringGiven a binary string s, return the number of non-empty substrings that have the same number of 0's and 1's, and all the 0's and all the 1's in these ... Topics: Two Pointers, String
- 449. Serialize and Deserialize BST - Medium - StringSerialization is converting a data structure or object into a sequence of bits so that it can be stored in a file or memory buffer, or transmitted acr... Topics: String, Tree, Depth-First Search, Breadth-First Search, Design, Binary Search Tree, Binary Tree
- 3275. Minimum Number of Pushes to Type Word I - Easy - StringYou are given a string word containing distinct lowercase English letters. Telephone keypads have keys mapped with distinct collections of lowercase E... Topics: Math, String, Greedy
- 2475. Largest Palindromic Number - Medium - StringYou are given a string num consisting of digits only. Return the largest palindromic integer (in the form of a string) that can be formed using digits... Topics: Hash Table, String, Greedy, Counting
- 3455. Minimum Length of String After Operations - Medium - StringYou 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 ... Topics: Hash Table, String, Counting
- 2260. Divide a String Into Groups of Size k - Easy - StringA string s can be partitioned into groups of size k using the following procedure: The first group consists of the first k characters of the string, t... Topics: String, Simulation
- 1777. Determine if Two Strings Are Close - Medium - StringTwo strings are considered close if you can attain one from the other using the following operations: Operation 1: Swap any two existing characters. F... Topics: Hash Table, String, Sorting, Counting
- 166. Fraction to Recurring Decimal - Medium - StringGiven two integers representing the numerator and denominator of a fraction, return the fraction in string format. If the fractional part is repeating... Topics: Hash Table, Math, String
- 556. Next Greater Element III - Medium - StringGiven a positive integer n, find the smallest integer which has exactly the same digits existing in the integer n and is greater in value than n. If n... Topics: Math, Two Pointers, String
- 1032. Satisfiability of Equality Equations - Medium - StringYou are given an array of strings equations that represent relationships between variables where each string equations[i] is of length 4 and takes one... Topics: Array, String, Union Find, Graph
- 1534. Minimum Number of Frogs Croaking - Medium - StringYou are given the string croakOfFrogs, which represents a combination of the string "croak" from different frogs, that is, multiple frogs can croak at... Topics: String, Counting
- 1651. Shuffle String - Easy - StringYou are given a string s and an integer array indices of the same length. The string s will be shuffled such that the character at the ith position mo... Topics: Array, String
- 648. Replace Words - Medium - StringIn English, we have a concept called root, which can be followed by some other word to form another longer word - let's call this word derivative. For... Topics: Array, Hash Table, String, Trie
- 257. Binary Tree Paths - Easy - StringGiven the root of a binary tree, return all root-to-leaf paths in any order. A leaf is a node with no children.... Topics: String, Backtracking, Tree, Depth-First Search, Binary Tree
- 749. Shortest Completing Word - Easy - StringGiven a string licensePlate and an array of strings words, find the shortest completing word in words. A completing word is a word that contains all t... Topics: Array, Hash Table, String
- 2819. Remove Trailing Zeros From a String - Easy - StringGiven a positive integer num represented as a string, return the integer num without trailing zeros as a string.... Topics: String
- 812. Rotate String - Easy - StringGiven two strings s and goal, return true if and only if s can become goal after some number of shifts on s. A shift on s consists of moving the leftm... Topics: String, String Matching
- 1360. Maximum Length of a Concatenated String with Unique Characters - Medium - StringYou are given an array of strings arr. A string s is formed by the concatenation of a subsequence of arr that has unique characters. Return the maximu... Topics: Array, String, Backtracking, Bit Manipulation
- 2654. Count the Number of Vowel Strings in Range - Easy - StringYou are given a 0-indexed array of string words and two integers left and right. A string is called a vowel string if it starts with a vowel character... Topics: Array, String, Counting
- 2221. Check if a Parentheses String Can Be Valid - Medium - StringA parentheses string is a non-empty string consisting only of '(' and ')'. It is valid if any of the following conditions is true: It is (). It can be... Topics: String, Stack, Greedy
- 1637. String Compression II - Hard - StringRun-length encoding is a string compression method that works by replacing consecutive identical characters (repeated 2 or more times) with the concat... Topics: String, Dynamic Programming
- 1859. Change Minimum Characters to Satisfy One of Three Conditions - Medium - StringYou are given two strings a and b that consist of lowercase letters. In one operation, you can change any character in a or b to any lowercase letter.... Topics: Hash Table, String, Counting, Prefix Sum
- 878. Shifting Letters - Medium - StringYou are given a string s of lowercase English letters and an integer array shifts of the same length. Call the shift() of a letter, the next letter in... Topics: Array, String, Prefix Sum
- 977. Distinct Subsequences II - Hard - StringGiven a string s, return the number of distinct non-empty subsequences of s. Since the answer may be very large, return it modulo 109 + 7. A subsequen... Topics: String, Dynamic Programming
- 862. Find And Replace in String - Medium - StringYou are given a 0-indexed string s that you must perform k replacement operations on. The replacement operations are given as three 0-indexed parallel... Topics: Array, Hash Table, String, Sorting
- 2348. Count Number of Texts - Medium - StringAlice is texting Bob using her phone. The mapping of digits to letters is shown in the figure below. In order to add a letter, Alice has to press the ... Topics: Hash Table, Math, String, Dynamic Programming
- 1786. Count the Number of Consistent Strings - Easy - StringYou are given a string allowed consisting of distinct characters and an array of strings words. A string is consistent if all characters in the string... Topics: Array, Hash Table, String, Bit Manipulation, Counting
- 1890. Sum of Beauty of All Substrings - Medium - StringThe beauty of a string is the difference in frequencies between the most frequent and least frequent characters. For example, the beauty of "abaacc" i... Topics: Hash Table, String, Counting
- 514. Freedom Trail - Hard - StringIn the video game Fallout 4, the quest "Road to Freedom" requires players to reach a metal dial called the "Freedom Trail Ring" and use the dial to sp... Topics: String, Dynamic Programming, Depth-First Search, Breadth-First Search
- 3426. Minimum Number of Chairs in a Waiting Room - Easy - StringYou are given a string s. Simulate events at each second i: If s[i] == 'E', a person enters the waiting room and takes one of the chairs in it. If s[i... Topics: String, Simulation
- 1737. Maximum Nesting Depth of the Parentheses - Easy - StringGiven a valid parentheses string s, return the nesting depth of s. The nesting depth is the maximum number of nested parentheses.... Topics: String, Stack
- 1920. Determine Color of a Chessboard Square - Easy - StringYou are given coordinates, a string that represents the coordinates of a square of the chessboard. Below is a chessboard for your reference. Return tr... Topics: Math, String
- 1437. Minimum Insertion Steps to Make a String Palindrome - Hard - StringGiven a string s. In one step you can insert any character at any index of the string. Return the minimum number of steps to make s palindrome. A Pali... Topics: String, Dynamic Programming
- 459. Repeated Substring Pattern - Easy - StringGiven a string s, check if it can be constructed by taking a substring of it and appending multiple copies of the substring together.... Topics: String, String Matching
- 30. Substring with Concatenation of All Words - Hard - StringYou are given a string s and an array of strings words. All the strings of words are of the same length. A concatenated string is a string that exactl... Topics: Hash Table, String, Sliding Window
- 1516. The k-th Lexicographical String of All Happy Strings of Length n - Medium - StringA happy string is a string that: consists only of letters of the set ['a', 'b', 'c']. s[i] != s[i + 1] for all values of i from 1 to s.length - 1 (str... Topics: String, Backtracking
- 2536. Determine if Two Events Have Conflict - Easy - StringYou are given two arrays of strings that represent two inclusive events that happened on the same day, event1 and event2, where: event1 = [startTime1,... Topics: Array, String
- 2757. Count of Integers - Hard - StringYou are given two numeric strings num1 and num2 and two integers max_sum and min_sum. We denote an integer x to be good if: num1 <= x <= num2 min_sum ... Topics: Math, String, Dynamic Programming
- 2345. Minimum Number of Operations to Convert Time - Easy - StringYou are given two strings current and correct representing two 24-hour times. 24-hour times are formatted as "HH:MM", where HH is between 00 and 23, a... Topics: String, Greedy
- 2429. Design a Food Rating System - Medium - StringDesign a food rating system that can do the following: Modify the rating of a food item listed in the system. Return the highest-rated food item for a... Topics: Array, Hash Table, String, Design, Heap (Priority Queue), Ordered Set
- 3243. Count the Number of Powerful Integers - Hard - StringYou are given three integers start, finish, and limit. You are also given a 0-indexed string s representing a positive integer. A positive integer x i... Topics: Math, String, Dynamic Programming
- 2559. Maximum Number of Non-overlapping Palindrome Substrings - Hard - StringYou are given a string s and a positive integer k. Select a set of non-overlapping substrings from the string s that satisfy the following conditions:... Topics: Two Pointers, String, Dynamic Programming, Greedy
- 481. Magical String - Medium - StringA magical string s consists of only '1' and '2' and obeys the following rules: The string s is magical because concatenating the number of contiguous ... Topics: Two Pointers, String
- 402. Remove K Digits - Medium - StringGiven string num representing a non-negative integer num, and an integer k, return the smallest possible integer after removing k digits from num.... Topics: String, Stack, Greedy, Monotonic Stack
- 2317. Count Collisions on a Road - Medium - StringThere are n cars on an infinitely long road. The cars are numbered from 0 to n - 1 from left to right and each car is present at a unique point. You a... Topics: String, Stack, Simulation
- 1160. Letter Tile Possibilities - Medium - StringYou have n tiles, where each tile has one letter tiles[i] printed on it. Return the number of possible non-empty sequences of letters you can make us... Topics: Hash Table, String, Backtracking, Counting
- 466. Count The Repetitions - Hard - StringWe define str = [s, n] as the string str which consists of the string s concatenated n times. For example, str == ["abc", 3] =="abcabcabc". We define ... Topics: String, Dynamic Programming
- 2736. Minimum Additions to Make Valid String - Medium - StringGiven a string word to which you can insert letters "a", "b" or "c" anywhere and any number of times, return the minimum number of letters that must b... Topics: String, Dynamic Programming, Stack, Greedy
- 3412. Permutation Difference between Two Strings - Easy - StringYou are given two strings s and t such that every character occurs at most once in s and t is a permutation of s. The permutation difference between s... Topics: Hash Table, String
- 187. Repeated DNA Sequences - Medium - StringThe DNA sequence is composed of a series of nucleotides abbreviated as 'A', 'C', 'G', and 'T'. For example, "ACGAATTCCG" is a DNA sequence. When study... Topics: Hash Table, String, Bit Manipulation, Sliding Window, Rolling Hash, Hash Function
- 524. Longest Word in Dictionary through Deleting - Medium - StringGiven a string s and a string array dictionary, return the longest string in the dictionary that can be formed by deleting some of the given string ch... Topics: Array, Two Pointers, String, Sorting
- 2137. Final Value of Variable After Performing Operations - Easy - StringThere is a programming language with only four operations and one variable X: ++X and X++ increments the value of the variable X by 1. --X and X-- dec... Topics: Array, String, Simulation
- 537. Complex Number Multiplication - Medium - StringA complex number can be represented as a string on the form "real+imaginaryi" where: real is the real part and is an integer in the range [-100, 100].... Topics: Math, String, Simulation
- 1871. Palindrome Partitioning IV - Hard - StringGiven a string s, return true if it is possible to split the string s into three non-empty palindromic substrings. Otherwise, return false. A str... Topics: String, Dynamic Programming
- 676. Implement Magic Dictionary - Medium - StringDesign a data structure that is initialized with a list of different words. Provided a string, you should determine if you can change exactly one char... Topics: Hash Table, String, Depth-First Search, Design, Trie
- 1720. Crawler Log Folder - Easy - StringThe Leetcode file system keeps a log each time some user performs a change folder operation. The operations are described below: "../" : Move to the p... Topics: Array, String, Stack
- 488. Zuma Game - Hard - StringYou are playing a variation of the game Zuma. In this variation of Zuma, there is a single row of colored balls on a board, where each ball can be col... Topics: String, Dynamic Programming, Stack, Breadth-First Search, Memoization
- 1648. Minimum Insertions to Balance a Parentheses String - Medium - StringGiven a parentheses string s containing only the characters '(' and ')'. A parentheses string is balanced if: Any left parenthesis '(' must have a cor... Topics: String, Stack, Greedy
- 2219. Maximum Number of Words Found in Sentences - Easy - StringA sentence is a list of words that are separated by a single space with no leading or trailing spaces. You are given an array of strings sentences, wh... Topics: Array, String
- 657. Robot Return to Origin - Easy - StringThere is a robot starting at the position (0, 0), the origin, on a 2D plane. Given a sequence of its moves, judge if this robot ends up at (0, 0) afte... Topics: String, Simulation
- 2220. Find All Possible Recipes from Given Supplies - Medium - StringYou have information about n different recipes. You are given a string array recipes and a 2D string array ingredients. The ith recipe has the name re... Topics: Array, Hash Table, String, Graph, Topological Sort
- 2328. Minimize Result by Adding Parentheses to Expression - Medium - StringYou are given a 0-indexed string expression of the form "<num1>+<num2>" where <num1> and <num2> represent positive integers. Add a pair of parentheses... Topics: String, Enumeration
- 2147. The Score of Students Solving Math Expression - Hard - StringYou are given a string s that contains digits 0-9, addition symbols '+', and multiplication symbols '*' only, representing a valid math expression of ... Topics: Array, Hash Table, Math, String, Dynamic Programming, Stack, Memoization
- 3770. Lexicographically Smallest Generated String - Hard - StringYou are given two strings, str1 and str2, of lengths n and m, respectively. A string word of length n + m - 1 is defined to be generated by str1 and s... Topics: String, Greedy, String Matching
- 1469. Minimum Number of Steps to Make Two Strings Anagram - Medium - StringYou are given two strings of the same length s and t. In one step you can choose any character of t and replace it with another character. Return the ... Topics: Hash Table, String, Counting
- 3784. Longest Common Prefix of K Strings After Removal - Hard - StringYou are given an array of strings words and an integer k. For each index i in the range [0, words.length - 1], find the length of the longest common p... Topics: Array, String, Trie
- 1430. Find the K-Beauty of a Number - Easy - StringThe k-beauty of an integer num is defined as the number of substrings of num when it is read as a string that meet the following conditions: It has a ... Topics: Math, String, Sliding Window
- 3019. Furthest Point From Origin - Easy - StringYou are given a string moves of length n consisting only of characters 'L', 'R', and '_'. The string represents your movement on a number line startin... Topics: String, Counting
- 306. Additive Number - Medium - StringAn additive number is a string whose digits can form an additive sequence. A valid additive sequence should contain at least three numbers. Except for... Topics: String, Backtracking
- 2319. Longest Substring of One Repeating Character - Hard - StringYou are given a 0-indexed string s. You are also given a 0-indexed string queryCharacters of length k and a 0-indexed array of integer indices queryIn... Topics: Array, String, Segment Tree, Ordered Set
- 1880. Largest Merge Of Two Strings - Medium - StringYou are given two strings word1 and word2. You want to construct a string merge in the following way: while either word1 or word2 are non-empty, choos... Topics: Two Pointers, String, Greedy
- 916. Decoded String at Index - Medium - StringYou are given an encoded string s. To decode the string to a tape, the encoded string is read one character at a time and the following steps are take... Topics: String, Stack
- 3451. String Compression III - Medium - StringGiven a string word, compress it using the following algorithm: Begin with an empty string comp. While word is not empty, use the following operation:... Topics: String
- 2088. Minimum Time to Type Word Using Special Typewriter - Easy - StringThere is a special typewriter with lowercase English letters 'a' to 'z' arranged in a circle with a pointer. A character can only be typed if the poin... Topics: String, Greedy
- 2140. Longest Subsequence Repeated k Times - Hard - StringYou are given a string s of length n, and an integer k. You are tasked to find the longest subsequence repeated k times in string s. A subsequence is ... Topics: String, Backtracking, Greedy, Counting, Enumeration
- 2755. Extra Characters in a String - Medium - StringYou are given a 0-indexed string s and a dictionary of words dictionary. You have to break s into one or more non-overlapping substrings such that eac... Topics: Array, Hash Table, String, Dynamic Programming, Trie
- 1302. Delete Characters to Make Fancy String - Easy - StringA fancy string is a string where no three consecutive characters are equal. Given a string s, delete the minimum possible number of characters from s ... Topics: String
- 1350. Remove Sub-Folders from the Filesystem - Medium - StringGiven a list of folders folder, return the folders after removing all sub-folders in those folders. You may return the answer in any order. If a folde... Topics: Array, String, Depth-First Search, Trie
- 2039. Sum Game - Medium - StringAlice and Bob take turns playing a game, with Alice starting first. You are given a string num of even length consisting of digits and '?' characters.... Topics: Math, String, Greedy, Game Theory
- 2389. Design a Text Editor - Hard - StringDesign a text editor with a cursor that can do the following: Add text to where the cursor is. Delete text from where the cursor is (simulating the ba... Topics: Linked List, String, Stack, Design, Simulation, Doubly-Linked List
- 2044. Number of Wonderful Substrings - Medium - StringA wonderful string is a string where at most one letter appears an odd number of times. For example, "ccjjc" and "abab" are wonderful, but "ab" is not... Topics: Hash Table, String, Bit Manipulation, Prefix Sum
- 3379. Score of a String - Easy - StringYou are given a string s. The score of a string is defined as the sum of the absolute difference between the ASCII values of adjacent characters. Retu... Topics: String
- 3948. Maximum Number of Subsequences After One Inserting - Medium - StringYou are given a string s consisting of uppercase English letters. You are allowed to insert at most one uppercase English letter at any position (incl... Topics: String, Dynamic Programming, Greedy, Prefix Sum
- 1356. Minimum Number of Moves to Make Palindrome - Hard - StringYou are given a string s consisting only of lowercase English letters. In one move, you can select any two adjacent characters of s and swap them. Ret... Topics: Two Pointers, String, Greedy, Binary Indexed Tree
- 2128. Reverse Prefix of Word - Easy - StringGiven a 0-indexed string word and a character ch, reverse the segment of word that starts at index 0 and ends at the index of the first occurrence of ... Topics: Two Pointers, String, Stack
- 1030. Smallest String Starting From Leaf - Medium - StringYou are given the root of a binary tree where each node has a value in the range [0, 25] representing the letters 'a' to 'z'. Return the lexicographic... Topics: String, Backtracking, Tree, Depth-First Search, Binary Tree
- 829. Subdomain Visit Count - Medium - StringA website domain "discuss.leetcode.com" consists of various subdomains. At the top level, we have "com", at the next level, we have "leetcode.com" and... Topics: Array, Hash Table, String, Counting
- 712. Minimum ASCII Delete Sum for Two Strings - Medium - StringGiven two strings s1 and s2, return the lowest ASCII sum of deleted characters to make two strings equal.... Topics: String, Dynamic Programming
- 1363. Greatest English Letter in Upper and Lower Case - Easy - StringGiven a string of English letters s, return the greatest English letter which occurs as both a lowercase and uppercase letter in s. The returned lette... Topics: Hash Table, String, Enumeration
- 2632. Apply Bitwise Operations to Make Strings Equal - Medium - StringYou are given two 0-indexed binary strings s and target of the same length n. You can do the following operation on s any number of times: Choose two ... Topics: String, Bit Manipulation
- 2079. Delete Duplicate Folders in System - Hard - StringDue to a bug, there are many duplicate folders in a file system. You are given a 2D array paths, where paths[i] is an array representing an absolute p... Topics: Array, Hash Table, String, Trie, Hash Function
- 3636. Check Balanced String - Easy - StringYou are given a string num consisting of only digits. A string of digits is called balanced if the sum of the digits at even indices is equal to the s... Topics: String
- 1282. Number of Valid Words for Each Puzzle - Hard - StringWith respect to a given puzzle string, a word is valid if both the following conditions are satisfied: word contains the first letter of puzzle. For e... Topics: Array, Hash Table, String, Bit Manipulation, Trie
- 1429. Verbal Arithmetic Puzzle - Hard - StringGiven an equation, represented by words on the left side and the result on the right side. You need to check if the equation is solvable under the fol... Topics: Array, Math, String, Backtracking
- 609. Find Duplicate File in System - Medium - StringGiven a list paths of directory info, including the directory path, and all the files with contents in this directory, return all the duplicate files ... Topics: Array, Hash Table, String
- 1941. Minimum Number of Operations to Make String Sorted - Hard - StringYou are given a string s (0-indexed). You are asked to perform the following operation on s until you get a sorted string: Find the larges... Topics: Math, String, Combinatorics
- 1490. Generate a String With Characters That Have Odd Counts - Easy - StringGiven an integer n, return a string with n characters such that each character in such string occurs an odd number of times. The returned string must ... Topics: String
- 3630. Total Characters in String After Transformations II - Hard - StringYou are given a string s consisting of lowercase English letters, an integer t representing the number of transformations to perform, and an array num... Topics: Hash Table, Math, String, Dynamic Programming, Counting
- 2572. Append Characters to String to Make Subsequence - Medium - StringYou are given two strings s and t consisting of only lowercase English letters. Return the minimum number of characters that need to be appended to th... Topics: Two Pointers, String, Greedy
- 1678. Number of Ways to Split a String - Medium - StringGiven a binary string s, you can split s into 3 non-empty strings s1, s2, and s3 where s1 + s2 + s3 = s. Return the number of ways s can be split such... Topics: Math, String
- 1744. Number of Ways to Form a Target String Given a Dictionary - Hard - StringYou are given a list of strings of the same length words and a string target. Your task is to form target using the given words under the following ru... Topics: Array, String, Dynamic Programming
- 2231. Find First Palindromic String in the Array - Easy - StringGiven an array of strings words, return the first palindromic string in the array. If there is no such string, return an empty string "". A string is ... Topics: Array, Two Pointers, String
- 3396. Valid Word - Easy - StringA word is considered valid if: It contains a minimum of 3 characters. It contains only digits (0-9), and English letters (uppercase and lowercase). It... Topics: String
- 3349. Maximum Length Substring With Two Occurrences - Easy - StringGiven a string s, return the maximum length of a substring such that it contains at most two occurrences of each character.... Topics: Hash Table, String, Sliding Window
- 3905. Partition String - Medium - StringGiven a string s, partition it into unique segments according to the following procedure: Start building a segment beginning at index 0. Continue exte... Topics: Hash Table, String, Trie, Simulation
- 2027. Maximum Number of Removable Characters - Medium - StringYou are given two strings s and p where p is a subsequence of s. You are also given a distinct 0-indexed integer array removable containing a subset o... Topics: Array, Two Pointers, String, Binary Search
- 935. Orderly Queue - Hard - StringYou are given a string s and an integer k. You can choose one of the first k letters of s and append it at the end of the string. Return the lexicogra... Topics: Math, String, Sorting
- 3912. Hexadecimal and Hexatrigesimal Conversion - Easy - StringYou are given an integer n. Return the concatenation of the hexadecimal representation of n2 and the hexatrigesimal representation of n3. A hexadecima... Topics: Math, String
- 2173. Number of Valid Words in a Sentence - Easy - StringA sentence consists of lowercase letters ('a' to 'z'), digits ('0' to '9'), hyphens ('-'), punctuation marks ('!', '.', and ','), and spaces (' ') onl... Topics: String
- 2563. Split Message Based on Limit - Hard - StringYou are given a string, message, and a positive integer, limit. You must split message into one or more parts based on limit. Each resulting part shou... Topics: String, Binary Search, Enumeration
- 1080. Camelcase Matching - Medium - StringGiven an array of strings queries and a string pattern, return a boolean array answer where answer[i] is true if queries[i] matches pattern, and false... Topics: Array, Two Pointers, String, Trie, String Matching
- 1885. Count Number of Homogenous Substrings - Medium - StringGiven a string s, return the number of homogenous substrings of s. Since the answer may be too large, return it modulo 109 + 7. A string is homogenous... Topics: Math, String
- 1112. Find Words That Can Be Formed by Characters - Easy - StringYou are given an array of strings words and a string chars. A string is good if it can be formed by characters from chars (each character can only be ... Topics: Array, Hash Table, String, Counting
- 1122. Longest Duplicate Substring - Hard - StringGiven a string s, consider all duplicated substrings: (contiguous) substrings of s that occur 2 or more times. The occurrences may overlap. Return any... Topics: String, Binary Search, Sliding Window, Rolling Hash, Suffix Array, Hash Function
- 1526. HTML Entity Parser - Medium - StringHTML entity parser is the parser that takes HTML code as input and replace all the entities of the special characters by the characters itself. The sp... Topics: Hash Table, String
- 1667. Find Kth Bit in Nth Binary String - Medium - StringGiven two positive integers n and k, the binary string Sn is formed as follows: S1 = "0" Si = Si - 1 + "1" + reverse(invert(Si - 1)) for i > 1 Where +... Topics: String, Recursion, Simulation
- 2470. Removing Stars From a String - Medium - StringYou are given a string s, which contains stars *. In one operation, you can: Choose a star in s. Remove the closest non-star character to its left, as... Topics: String, Stack, Simulation
- 3930. Longest Palindromic Path in Graph - Hard - StringYou are given an integer n and an undirected graph with n nodes labeled from 0 to n - 1 and a 2D array edges, where edges[i] = [ui, vi] indicates an e... Topics: String, Dynamic Programming, Bit Manipulation, Graph, Bitmask
- 2217. Step-By-Step Directions From a Binary Tree Node to Another - Medium - StringYou are given the root of a binary tree with n nodes. Each node is uniquely assigned a value from 1 to n. You are also given an integer startValue rep... Topics: String, Tree, Depth-First Search, Binary Tree
- 2463. Minimum Recolors to Get K Consecutive Black Blocks - Easy - StringYou are given a 0-indexed string blocks of length n, where blocks[i] is either 'W' or 'B', representing the color of the ith block. The characters 'W'... Topics: String, Sliding Window
- 3931. Process String with Special Operations I - Medium - StringYou are given a string s consisting of lowercase English letters and the special characters: *, #, and %. Build a new string result by processing s ac... Topics: String, Simulation
- 3939. Process String with Special Operations II - Hard - StringYou are given a string s consisting of lowercase English letters and the special characters: '*', '#', and '%'. You are also given an integer k. Build... Topics: String, Simulation
- 1065. Binary String With Substrings Representing 1 To N - Medium - StringGiven a binary string s and a positive integer n, return true if the binary representation of all the integers in the range [1, n] are substrings of s... Topics: Hash Table, String, Bit Manipulation, Sliding Window
- 2603. Reward Top K Students - Medium - StringYou are given two string arrays positive_feedback and negative_feedback, containing the words denoting positive and negative feedback, respectively. N... Topics: Array, Hash Table, String, Sorting, Heap (Priority Queue)
- 692. Top K Frequent Words - Medium - StringGiven an array of strings words and an integer k, return the k most frequent strings. Return the answer sorted by the frequency from highest to lowest... Topics: Array, Hash Table, String, Trie, Sorting, Heap (Priority Queue), Bucket Sort, Counting
- 2877. Shortest String That Contains Three Strings - Medium - StringGiven three strings a, b, and c, your task is to find a string that has the minimum length and contains all three strings as substrings. If there are ... Topics: String, Greedy, Enumeration
- 3540. Hash Divided String - Medium - StringYou are given a string s of length n and an integer k, where n is a multiple of k. Your task is to hash the string s into a new string called result, ... Topics: String, Simulation
- 869. Similar String Groups - Hard - StringTwo strings, X and Y, are considered similar if either they are identical or we can make them equivalent by swapping at most two letters (in distinct ... Topics: Array, Hash Table, String, Depth-First Search, Breadth-First Search, Union Find
- 649. Dota2 Senate - Medium - StringIn the world of Dota2, there are two parties: the Radiant and the Dire. The Dota2 senate consists of senators coming from two parties. Now the Senate ... Topics: String, Greedy, Queue
- 1700. Minimum Time to Make Rope Colorful - Medium - StringAlice has n balloons arranged on a rope. You are given a 0-indexed string colors where colors[i] is the color of the ith balloon. Alice wants the rope... Topics: Array, String, Dynamic Programming, Greedy
- 2494. Sum of Prefix Scores of Strings - Hard - StringYou are given an array words of size n consisting of non-empty strings. We define the score of a string term as the number of strings words[i] such th... Topics: Array, String, Trie, Counting
- 1987. Substrings of Size Three with Distinct Characters - Easy - StringA string is good if there are no repeated characters. Given a string s, return the number of good substrings of length three in s. Note tha... Topics: Hash Table, String, Sliding Window, Counting
- 2134. Maximize the Confusion of an Exam - Medium - StringA teacher is writing a test with n true/false questions, with 'T' denoting true and 'F' denoting false. He wants to confuse the students by maximizing... Topics: String, Binary Search, Sliding Window, Prefix Sum
- 1562. People Whose List of Favorite Companies Is Not a Subset of Another List - Medium - StringGiven the array favoriteCompanies where favoriteCompanies[i] is the list of favorites companies for the ith person (indexed from 0). Return the indice... Topics: Array, Hash Table, String
- 1923. Sentence Similarity III - Medium - StringYou are given two strings sentence1 and sentence2, each representing a sentence composed of words. A sentence is a list of words that are separated by... Topics: Array, Two Pointers, String
- 3701. Minimum Cost Good Caption - Hard - StringYou are given a string caption of length n. A good caption is a string where every character appears in groups of at least 3 consecutive occurrences. ... Topics: String, Dynamic Programming
- 2166. Number of Valid Move Combinations On Chessboard - Hard - StringThere is an 8 x 8 chessboard containing n pieces (rooks, queens, or bishops). You are given a string array pieces of length n, where pieces[i] describ... Topics: Array, String, Backtracking, Simulation
- 2395. Longest Binary Subsequence Less Than or Equal to K - Medium - StringYou are given a binary string s and a positive integer k. Return the length of the longest subsequence of s that makes up a binary number less than or... Topics: String, Dynamic Programming, Greedy, Memoization
- 2197. Decode the Slanted Ciphertext - Medium - StringA string originalText is encoded using a slanted transposition cipher to a string encodedText with the help of a matrix having a fixed number of rows ... Topics: String, Simulation
- 2615. Make Number of Distinct Characters Equal - Medium - StringYou are given two 0-indexed strings word1 and word2. A move consists of choosing two indices i and j such that 0 <= i < word1.length and 0 <= j < word... Topics: Hash Table, String, Counting
- 851. Goat Latin - Easy - StringYou are given a string sentence that consist of words separated by spaces. Each word consists of lowercase and uppercase letters only. We would like t... Topics: String
- 1341. Split a String in Balanced Strings - Easy - StringBalanced strings are those that have an equal quantity of 'L' and 'R' characters. Given a balanced string s, split it into some number of substrings s... Topics: String, Greedy, Counting
- 1273. Compare Strings by Frequency of the Smallest Character - Medium - StringLet the function f(s) be the frequency of the lexicographically smallest character in a non-empty string s. For example, if s = "dcce" then f(s) = 2 b... Topics: Array, Hash Table, String, Binary Search, Sorting
- 3195. Separate Black and White Balls - Medium - StringThere are n balls on a table, each ball has a color black or white. You are given a 0-indexed binary string s of length n, where 1 and 0 represent bla... Topics: Two Pointers, String, Greedy
- 2816. Lexicographically Smallest Palindrome - Easy - StringYou are given a string s consisting of lowercase English letters, and you are allowed to perform operations on it. In one operation, you can replace a... Topics: Two Pointers, String, Greedy
- 3405. Count the Number of Special Characters II - Medium - StringYou are given a string word. A letter c is called special if it appears both in lowercase and uppercase in word, and every lowercase occurrence of c a... Topics: Hash Table, String
- 3303. Find Beautiful Indices in the Given Array II - Hard - StringYou are given a 0-indexed string s, a string a, a string b, and an integer k. An index i is beautiful if: 0 <= i <= s.length - a.length s[i..(i + a.le... Topics: Two Pointers, String, Binary Search, Rolling Hash, String Matching, Hash Function
- 3786. Longest Palindromic Subsequence After at Most K Operations - Medium - StringYou are given a string s and an integer k. In one operation, you can replace the character at any position with the next or previous letter in the alp... Topics: String, Dynamic Programming
- 2232. Adding Spaces to a String - Medium - StringYou are given a 0-indexed string s and a 0-indexed integer array spaces that describes the indices in the original string where spaces will be added. ... Topics: Array, Two Pointers, String, Simulation
- 3552. Find the Largest Palindrome Divisible by K - Hard - StringYou are given two positive integers n and k. An integer x is called k-palindromic if: x is a palindrome. x is divisible by k. Return the largest integ... Topics: Math, String, Dynamic Programming, Greedy, Number Theory
- 3736. Find Valid Pair of Adjacent Digits in String - Easy - StringYou are given a string s consisting only of digits. A valid pair is defined as two adjacent digits in s such that: The first digit is not equal to the... Topics: Hash Table, String, Counting
- 2149. Remove Colored Pieces if Both Neighbors are the Same Color - Medium - StringThere are n pieces arranged in a line, and each piece is colored either by 'A' or by 'B'. You are given a string colors of length n where colors[i] is... Topics: Math, String, Greedy, Game Theory
- 1433. Encrypt and Decrypt Strings - Hard - StringYou are given a character array keys containing unique characters and a string array values containing strings of length 2. You are also given another... Topics: Array, Hash Table, String, Design, Trie
- 3024. String Transformation - Hard - StringYou are given two strings s and t of equal length n. You can perform the following operation on the string s: Remove a suffix of s of length l where 0... Topics: Math, String, Dynamic Programming, String Matching
- 1557. Check If a String Contains All Binary Codes of Size K - Medium - StringGiven a binary string s and an integer k, return true if every binary code of length k is a substring of s. Otherwise, return false.... Topics: Hash Table, String, Bit Manipulation, Rolling Hash, Hash Function
- 2800. Minimum String Length After Removing Substrings - Easy - StringYou are given a string s consisting only of uppercase English letters. You can apply some operations to this string where, in one operation, you can r... Topics: String, Stack, Simulation
- 1533. Display Table of Food Orders in a Restaurant - Medium - StringGiven the array orders, which represents the orders that customers have done in a restaurant. More specifically orders[i]=[customerNamei,tableNumberi,... Topics: Array, Hash Table, String, Sorting, Ordered Set
- 3580. Find the Occurrence of First Almost Equal Substring - Hard - StringYou are given two strings s and pattern. A string x is called almost equal to y if you can change at most one character in x to make it identical to y... Topics: String, String Matching
- 1520. Number of Steps to Reduce a Number in Binary Representation to One - Medium - StringGiven the binary representation of an integer as a string s, return the number of steps to reduce it to 1 under the following rules: If the current nu... Topics: String, Bit Manipulation, Simulation
- 2465. Shifting Letters II - Medium - StringYou are given a string s of lowercase English letters and a 2D integer array shifts where shifts[i] = [starti, endi, directioni]. For every i, shift t... Topics: Array, String, Prefix Sum
- 2361. Calculate Digit Sum of a String - Easy - StringYou are given a string s consisting of digits and an integer k. A round can be completed if the length of s is greater than k. In one round, do the fo... Topics: String, Simulation
- 282. Expression Add Operators - Hard - StringGiven a string num that contains only digits and an integer target, return all possibilities to insert the binary operators '+', '-', and/or '*' betwe... Topics: Math, String, Backtracking
- 979. DI String Match - Easy - StringA permutation perm of n + 1 integers of all the integers in the range [0, n] can be represented as a string s of length n where: s[i] == 'I' if perm[i... Topics: Array, Two Pointers, String, Greedy
- 3872. Find Most Frequent Vowel and Consonant - Easy - StringYou are given a string s consisting of lowercase English letters ('a' to 'z'). Your task is to: Find the vowel (one of 'a', 'e', 'i', 'o', or 'u') wit... Topics: Hash Table, String, Counting
- 1915. Check if One String Swap Can Make Strings Equal - Easy - StringYou are given two strings s1 and s2 of equal length. A string swap is an operation where you choose two indices in a string (not necessarily different... Topics: Hash Table, String, Counting
- 1904. Second Largest Digit in a String - Easy - StringGiven an alphanumeric string s, return the second largest numerical digit that appears in s, or -1 if it does not exist. An alphanumeric string is a s... Topics: Hash Table, String
- 1884. Minimum Changes To Make Alternating Binary String - Easy - StringYou are given a string s consisting only of the characters '0' and '1'. In one operation, you can change any '0' to '1' or vice versa. The string is c... Topics: String
- 2309. Maximize Number of Subsequences in a String - Medium - StringYou are given a 0-indexed string text and another 0-indexed string pattern of length 2, both of which consist of only lowercase English letters. You c... Topics: String, Greedy, Prefix Sum
- 2292. Counting Words With a Given Prefix - Easy - StringYou 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... Topics: Array, String, String Matching
- 2177. Check Whether Two Strings are Almost Equivalent - Easy - StringTwo strings word1 and word2 are considered almost equivalent if the differences between the frequencies of each letter from 'a' to 'z' between word1 a... Topics: Hash Table, String, Counting
- 942. Super Palindromes - Hard - StringLet's say a positive integer is a super-palindrome if it is a palindrome, and it is also the square of a palindrome. Given two positive integers left ... Topics: Math, String, Enumeration
- 2025. Redistribute Characters to Make All Strings Equal - Easy - StringYou are given an array of strings words (0-indexed). In one operation, pick two distinct indices i and j, where words[i] is a non-empty string, and mo... Topics: Hash Table, String, Counting
- 2237. Longest Palindrome by Concatenating Two Letter Words - Medium - StringYou are given an array of strings words. Each element of words consists of two lowercase English letters. Create the longest possible palindrome by se... Topics: Array, Hash Table, String, Greedy, Counting
- 388. Longest Absolute File Path - Medium - StringSuppose we have a file system that stores both files and directories. An example of one system is represented in the following picture: Here, we have ... Topics: String, Stack, Depth-First Search
- 2708. Find the String with LCP - Hard - StringWe define the lcp matrix of any 0-indexed string word of n lowercase English letters as an n x n grid such that: lcp[i][j] is equal to the length of t... Topics: Array, String, Dynamic Programming, Greedy, Union Find, Matrix
- 3462. Vowels Game in a String - Medium - StringAlice and Bob are playing a game on a string. You are given a string s, Alice and Bob will take turns playing the following game where Alice starts fi... Topics: Math, String, Brainteaser, Game Theory
- 2239. Execution of All Suffix Instructions Staying in a Grid - Medium - StringThere is an n x n grid, with the top-left cell at (0, 0) and the bottom-right cell at (n - 1, n - 1). You are given the integer n and an integer array... Topics: String, Simulation
- 1566. Check If a Word Occurs As a Prefix of Any Word in a Sentence - Easy - StringGiven a sentence that consists of some words separated by a single space, and a searchWord, check if searchWord is a prefix of any word in sentence. R... Topics: Two Pointers, String, String Matching
- 2256. Count Words Obtained After Adding a Letter - Medium - StringYou are given two 0-indexed arrays of strings startWords and targetWords. Each string consists of lowercase English letters only. For each string in t... Topics: Array, Hash Table, String, Bit Manipulation, Sorting
- 1473. Find the Longest Substring Containing Vowels in Even Counts - Medium - StringGiven the string s, return the size of the longest substring containing each vowel an even number of times. That is, 'a', 'e', 'i', 'o', and 'u' must ... Topics: Hash Table, String, Bit Manipulation, Prefix Sum
- 1894. Merge Strings Alternately - Easy - StringYou 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 t... Topics: Two Pointers, String
- 2251. Number of Ways to Divide a Long Corridor - Hard - StringAlong a long library corridor, there is a line of seats and decorative plants. You are given a 0-indexed string corridor of length n consisting of let... Topics: Math, String, Dynamic Programming
- 1297. Maximum Number of Balloons - Easy - StringGiven a string text, you want to use the characters of text to form as many instances of the word "balloon" as possible. You can use each character in... Topics: Hash Table, String, Counting
- 1660. Thousand Separator - Easy - StringGiven an integer n, add a dot (".") as the thousands separator and return it in string format.... Topics: String
- 1530. Check If a String Can Break Another String - Medium - StringGiven two strings: s1 and s2 with the same size, check if some permutation of string s1 can break some permutation of string s2 or vice-versa. In othe... Topics: String, Greedy, Sorting
- 3634. Find Mirror Score of a String - Medium - StringYou are given a string s. We define the mirror of a letter in the English alphabet as its corresponding letter when the alphabet is reversed. For exam... Topics: Hash Table, String, Stack, Simulation
- 3384. Minimum Number of Operations to Make Word K-Periodic - Medium - StringYou are given a string word of size n, and an integer k such that k divides n. In one operation, you can pick any two indices i and j, that are divisi... Topics: Hash Table, String, Counting
- 2576. Minimum Penalty for a Shop - Medium - StringYou are given the customer visit log of a shop represented by a 0-indexed string customers consisting only of characters 'N' and 'Y': if the ith chara... Topics: String, Prefix Sum
- 3309. Count Prefix and Suffix Pairs I - Easy - StringYou are given a 0-indexed string array words. Let's define a boolean function isPrefixAndSuffix that takes two strings, str1 and str2: isPrefixAndSuff... Topics: Array, String, Trie, Rolling Hash, String Matching, Hash Function
- 2881. Split Strings by Separator - Easy - StringGiven an array of strings words and a character separator, split each string in words by separator. Return an array of strings containing the new stri... Topics: Array, String
- 1097. Stream of Characters - Hard - StringDesign an algorithm that accepts a stream of characters and checks if a suffix of these characters is a string of a given array of strings words. For ... Topics: Array, String, Design, Trie, Data Stream
- 1434. Decrypt String from Alphabet to Integer Mapping - Easy - StringYou are given a string s formed by digits and '#'. We want to map s to English lowercase characters as follows: Characters ('a' to 'i') are represente... Topics: String
- 331. Verify Preorder Serialization of a Binary Tree - Medium - StringOne way to serialize a binary tree is to use preorder traversal. When we encounter a non-null node, we record the node's value. If it is a null node, ... Topics: String, Stack, Tree, Binary Tree
- 1714. Rearrange Spaces Between Words - Easy - StringYou are given a string text of words that are placed among some number of spaces. Each word consists of one or more lowercase English letters and are ... Topics: String
- 2390. Naming a Company - Hard - StringYou are given an array of strings ideas that represents a list of names to be used in the process of naming a company. The process of naming a company... Topics: Array, Hash Table, String, Bit Manipulation, Enumeration
- 1636. Number of Substrings With Only 1s - Medium - StringGiven a binary string s, return the number of substrings with all characters 1's. Since the answer may be too large, return it modulo 109 + 7.... Topics: Math, String
- 1543. Simplified Fractions - Medium - StringGiven an integer n, return a list of all simplified fractions between 0 and 1 (exclusive) such that the denominator is less-than-or-equal-to n. You ca... Topics: Math, String, Number Theory
- 539. Minimum Time Difference - Medium - StringGiven a list of 24-hour clock time points in "HH:MM" format, return the minimum minutes difference between any two time-points in the list.... Topics: Array, Math, String, Sorting
- 2978. Check if Strings Can be Made Equal With Operations II - Medium - StringYou are given two strings s1 and s2, both of length n, consisting of lowercase English letters. You can apply the following operation on any of the tw... Topics: Hash Table, String, Sorting
- 1934. Evaluate the Bracket Pairs of a String - Medium - StringYou are given a string s that contains some bracket pairs, with each pair containing a non-empty key. For example, in the string "(name)is(age)yearsol... Topics: Array, Hash Table, String
- 2184. Check if an Original String Exists Given Two Encoded Strings - Hard - StringAn original string, consisting of lowercase English letters, can be encoded by the following steps: Arbitrarily split it into a sequence of some numbe... Topics: String, Dynamic Programming
- 3447. Clear Digits - Easy - StringYou are given a string s. Your task is to remove all digits by doing this operation repeatedly: Delete the first digit and the closest non-digit chara... Topics: String, Stack, Simulation
- 1512. Design Underground System - Medium - StringAn underground railway system is keeping track of customer travel times between different stations. They are using this data to calculate the average ... Topics: Hash Table, String, Design
- 2520. Using a Robot to Print the Lexicographically Smallest String - Medium - StringYou are given a string s and a robot that currently holds an empty string t. Apply one of the following operations until s and t are both empty: Remov... Topics: Hash Table, String, Stack, Greedy
- 2076. Sum of Digits of String After Convert - Easy - StringYou are given a string s consisting of lowercase English letters, and an integer k. Your task is to convert the string into an integer by a special pr... Topics: String, Simulation
- 3207. Make Three Strings Equal - Easy - StringYou are given three strings: s1, s2, and s3. In one operation you can choose one of these strings and delete its rightmost character. Note that you ca... Topics: String
- 2293. Minimum Number of Steps to Make Two Strings Anagram II - Medium - StringYou are given two strings s and t. In one step, you can append any character to either s or t. Return the minimum number of steps to make s and t anag... Topics: Hash Table, String, Counting
- 3866. Minimum Steps to Convert String with Operations - Hard - StringYou are given two strings, word1 and word2, of equal length. You need to transform word1 into word2. For this, divide word1 into one or more contiguou... Topics: String, Dynamic Programming, Greedy
- 2921. Count Stepping Numbers in Range - Hard - StringGiven two positive integers low and high represented as strings, find the count of stepping numbers in the inclusive range [low, high]. A stepping num... Topics: String, Dynamic Programming
- 2337. Remove Digit From Number to Maximize Result - Easy - StringYou are given a string number representing a positive integer and a character digit. Return the resulting string after removing exactly one occurrence... Topics: String, Greedy, Enumeration
- 2701. Subsequence With the Minimum Score - Hard - StringYou are given two strings s and t. You are allowed to remove any number of characters from the string t. The score of the string is 0 if no characters... Topics: Two Pointers, String, Binary Search
- 3360. Minimum Deletions to Make String K-Special - Medium - StringYou are given a string word and an integer k. We consider word to be k-special if |freq(word[i]) - freq(word[j])| <= k for all indices i and j in the ... Topics: Hash Table, String, Greedy, Sorting, Counting
- 3683. Find the Lexicographically Largest String From the Box I - Medium - StringYou are given a string word, and an integer numFriends. Alice is organizing a game for her numFriends friends. There are multiple rounds in the game, ... Topics: Two Pointers, String, Enumeration
- 3867. Lexicographically Smallest String After Adjacent Removals - Hard - StringYou are given a string s consisting of lowercase English letters. You can perform the following operation any number of times (including zero): Remove... Topics: String, Dynamic Programming
- 3541. Report Spam Message - Medium - StringYou are given an array of strings message and an array of strings bannedWords. An array of words is considered spam if there are at least two words in... Topics: Array, Hash Table, String
- 1449. Print Words Vertically - Medium - StringGiven a string s. Return all the words vertically in the same order in which they appear in s. Words are returned as a list of strings, complete with ... Topics: Array, String, Simulation
- 1858. Latest Time by Replacing Hidden Digits - Easy - StringYou are given a string time in the form of hh:mm, where some of the digits in the string are hidden (represented by ?). The valid times are those inc... Topics: String, Greedy
- 3713. Frequencies of Shortest Supersequences - Hard - StringYou are given an array of strings words. Find all shortest common supersequences (SCS) of words that are not permutations of each other. A shortest co... Topics: Array, String, Bit Manipulation, Graph, Topological Sort, Enumeration
- 3588. Count The Number of Winning Sequences - Hard - StringAlice and Bob are playing a fantasy battle game consisting of n rounds where they summon one of three magical creatures each round: a Fire Dragon, a W... Topics: String, Dynamic Programming
- 3761. Maximum Difference Between Even and Odd Frequency II - Hard - StringYou are given a string s and an integer k. Your task is to find the maximum difference between the frequency of two characters, freq[a] - freq[b], in ... Topics: String, Sliding Window, Enumeration, Prefix Sum
- 3617. Find the Original Typed String I - Easy - StringAlice is attempting to type a specific string on her computer. However, she tends to be clumsy and may press a key for too long, resulting in a charac... Topics: String
- 3356. Shortest Uncommon Substring in an Array - Medium - StringYou are given an array arr of size n consisting of non-empty strings. Find a string array answer of size n such that: answer[i] is the shortest substr... Topics: Array, Hash Table, String, Trie
- 980. Find the Shortest Superstring - Hard - StringGiven an array of strings words, return the smallest string that contains each string in words as a substring. If there are multiple valid strings of ... Topics: Array, String, Dynamic Programming, Bit Manipulation, Bitmask
- 3618. Find the Original Typed String II - Hard - StringAlice is attempting to type a specific string on her computer. However, she tends to be clumsy and may press a key for too long, resulting in a charac... Topics: String, Dynamic Programming, Prefix Sum
- 3813. Smallest Palindromic Rearrangement II - Hard - StringYou are given a palindromic string s and an integer k. Return the k-th lexicographically smallest palindromic permutation of s. If there are fewer tha... Topics: Hash Table, Math, String, Combinatorics, Counting
- 3754. Maximum Manhattan Distance After K Changes - Medium - StringYou are given a string s consisting of the characters 'N', 'S', 'E', and 'W', where s[i] indicates movements in an infinite grid: 'N' : Move north by ... Topics: Hash Table, Math, String, Counting
- 3753. Maximum Difference Between Even and Odd Frequency I - Easy - StringYou are given a string s consisting of lowercase English letters. Your task is to find the maximum difference diff = freq(a1) - freq(a2) between the f... Topics: Hash Table, String, Counting
- 1873. Longest Nice Substring - Easy - StringA string s is nice if, for every letter of the alphabet that s contains, it appears both in uppercase and lowercase. For example, "abABB" is nice beca... Topics: Hash Table, String, Divide and Conquer, Bit Manipulation, Sliding Window
- 2887. Sort Vowels in a String - Medium - StringGiven a 0-indexed string s, permute s to get a new string t such that: All consonants remain in their original places. More formally, if there is an i... Topics: String, Sorting
- 1532. Reformat The String - Easy - StringYou are given an alphanumeric string s. (Alphanumeric string is a string consisting of lowercase English letters and digits). You have to find a permu... Topics: String
- 2884. Length of the Longest Valid Substring - Hard - StringYou are given a string word and an array of strings forbidden. A string is called valid if none of its substrings are present in forbidden. Return the... Topics: Array, Hash Table, String, Sliding Window
- 1502. Construct K Palindrome Strings - Medium - StringGiven a string s and an integer k, return true if you can use all the characters in s to construct non-empty k palindrome strings or false otherwise.... Topics: Hash Table, String, Greedy, Counting
- 3893. Generate Tag for Video Caption - Easy - StringYou are given a string caption representing the caption for a video. The following actions must be performed in order to generate a valid tag for the ... Topics: String, Simulation
- 3860. Resulting String After Adjacent Removals - Medium - StringYou are given a string s consisting of lowercase English letters. You must repeatedly perform the following operation while the string s has at least ... Topics: String, Stack, Simulation
- 827. Expressive Words - Medium - StringSometimes people repeat letters to represent extra feeling. For example: "hello" -> "heeellooo" "hi" -> "hiiii" In these strings like "heeellooo", we ... Topics: Array, Two Pointers, String
- 3445. Lexicographically Minimum String After Removing Stars - Medium - StringYou are given a string s. It may contain any number of '*' characters. Your task is to remove all '*' characters. While there is a '*', do the followi... Topics: Hash Table, String, Stack, Greedy, Heap (Priority Queue)
- 1321. Get Equal Substrings Within Budget - Medium - StringYou are given two strings s and t of the same length and an integer maxCost. You want to change s to t. Changing the ith character of s to ith charact... Topics: String, Binary Search, Sliding Window, Prefix Sum
- 2300. Construct String With Repeat Limit - Medium - StringYou are given a string s and an integer repeatLimit. Construct a new string repeatLimitedString using the characters of s such that no letter appears ... Topics: Hash Table, String, Greedy, Heap (Priority Queue), Counting
- 2532. Remove Letter To Equalize Frequency - Easy - StringYou are given a 0-indexed string word, consisting of lowercase English letters. You need to select one index and remove the letter at that index from ... Topics: Hash Table, String, Counting
- 2727. Number of Senior Citizens - Easy - StringYou are given a 0-indexed array of strings details. Each element of details provides information about a given passenger compressed into a string of l... Topics: Array, String
- 2010. Check if Word Equals Summation of Two Words - Easy - StringThe letter value of a letter is its position in the alphabet starting from 0 (i.e. 'a' -> 0, 'b' -> 1, 'c' -> 2, etc.). The numerical value of some st... Topics: String
- 3569. Count of Substrings Containing Every Vowel and K Consonants II - Medium - StringYou are given a string word and a non-negative integer k. Return the total number of substrings of word that contain every vowel ('a', 'e', 'i', 'o', ... Topics: Hash Table, String, Sliding Window
- 3857. Find Maximum Number of Non Intersecting Substrings - Medium - StringYou are given a string word. Return the maximum number of non-intersecting substrings of word that are at least four characters long and start and end... Topics: Hash Table, String, Dynamic Programming, Greedy
- 1746. Largest Substring Between Two Equal Characters - Easy - StringGiven a string s, return the length of the longest substring between two equal characters, excluding the two characters. If there is no such substring... Topics: Hash Table, String
- 778. Reorganize String - Medium - StringGiven a string s, rearrange the characters of s so that any two adjacent characters are not the same. Return any possible rearrangement of s or return... Topics: Hash Table, String, Greedy, Sorting, Heap (Priority Queue), Counting
- 1707. Check If String Is Transformable With Substring Sort Operations - Hard - StringGiven two strings s and t, transform string s into string t using the following operation any number of times: Choose a non-empty substring in s and s... Topics: String, Greedy, Sorting
- 3637. Count Number of Balanced Permutations - Hard - StringYou are given a string num. A string of digits is called balanced if the sum of the digits at even indices is equal to the sum of the digits at odd in... Topics: Math, String, Dynamic Programming, Combinatorics
- 3815. Sum of Largest Prime Substrings - Medium - StringGiven a string s, find the sum of the 3 largest unique prime numbers that can be formed using any of its substrings. Return the sum of the three large... Topics: Hash Table, Math, String, Sorting, Number Theory
- 3566. Find the Sequence of Strings Appeared on the Screen - Medium - StringYou are given a string target. Alice is going to type target on her computer using a special keyboard that has only two keys: Key 1 appends the charac... Topics: String, Simulation
- 857. Positions of Large Groups - Easy - StringIn a string s of lowercase letters, these letters form consecutive groups of the same character. For example, a string like s = "abbxxxxzyy" has the g... Topics: String
- 1698. Replace All ?'s to Avoid Consecutive Repeating Characters - Easy - StringGiven a string s containing only lowercase English letters and the '?' character, convert all the '?' characters into lowercase letters such that the ... Topics: String
- 2325. Number of Ways to Select Buildings - Medium - StringYou are given a 0-indexed binary string s which represents the types of buildings along a street where: s[i] = '0' denotes that the ith building is an... Topics: String, Dynamic Programming, Prefix Sum
- 3482. Construct String with Minimum Cost - Hard - StringYou are given a string target, an array of strings words, and an integer array costs, both arrays of the same length. Imagine an empty string s. You c... Topics: Array, String, Dynamic Programming, Suffix Array
- 2095. Minimum Number of Swaps to Make the String Balanced - Medium - StringYou 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 strin... Topics: Two Pointers, String, Stack, Greedy
- 2977. Check if a String Is an Acronym of Words - Easy - StringGiven an array of strings words and a string s, determine if s is an acronym of words. The string s is considered an acronym of words if it can be for... Topics: Array, String
- 1629. Minimum Possible Integer After at Most K Adjacent Swaps On Digits - Hard - StringYou are given a string num representing the digits of a very large integer and an integer k. You are allowed to swap any two adjacent digits of the in... Topics: String, Greedy, Binary Indexed Tree, Segment Tree
- 986. Largest Time for Given Digits - Medium - StringGiven an array arr of 4 digits, find the latest 24-hour time that can be made using each digit exactly once. 24-hour times are formatted as "HH:MM", w... Topics: Array, String, Backtracking, Enumeration
- 3793. Longest Palindrome After Substring Concatenation I - Medium - StringYou are given two strings, s and t. You can create a new string by selecting a substring from s (possibly empty) and a substring from t (possibly empt... Topics: Two Pointers, String, Dynamic Programming, Enumeration
- 858. Masking Personal Information - Medium - StringYou are given a personal information string s, representing either an email address or a phone number. Return the masked personal information using th... Topics: String
- 1666. Make The String Great - Easy - StringGiven a string s of lower and upper case English letters. A good string is a string which doesn't have two adjacent characters s[i] and s[i + 1] where... Topics: String, Stack
- 1647. Can Convert String in K Moves - Medium - StringGiven two strings s and t, your goal is to convert s into t in k moves or less. During the ith (1 <= i <= k) move you can: Choose any index j (1-index... Topics: Hash Table, String
- 3774. Check If Digits Are Equal in String After Operations II - Hard - StringYou are given a string s consisting of digits. Perform the following operation repeatedly until the string has exactly two digits: For each pair of co... Topics: Math, String, Combinatorics, Number Theory
- 1933. Number of Different Integers in a String - Easy - StringYou are given a string word that consists of digits and lowercase English letters. You will replace every non-digit character with a space. For exampl... Topics: Hash Table, String
- 2580. Circular Sentence - Easy - StringA sentence is a list of words that are separated by a single space with no leading or trailing spaces. For example, "Hello World", "HELLO", "hello wor... Topics: String
- 808. Number of Matching Subsequences - Medium - StringGiven a string s and an array of strings words, return the number of words[i] that is a subsequence of s. A subsequence of a string is a new string ge... Topics: Array, Hash Table, String, Binary Search, Dynamic Programming, Trie, Sorting
- 3312. Number of Changing Keys - Easy - StringYou are given a 0-indexed string s typed by a user. Changing a key is defined as using a key different from the last used key. For example, s = "ab" h... Topics: String
- 318. Maximum Product of Word Lengths - Medium - StringGiven a string array words, return the maximum value of length(word[i]) * length(word[j]) where the two words do not share common letters. If no such ... Topics: Array, String, Bit Manipulation
- 2008. Minimum Cost to Change the Final Value of Expression - Hard - StringYou are given a valid boolean expression as a string expression consisting of the characters '1','0','&' (bitwise AND operator),'|' (bitwise OR operat... Topics: Math, String, Dynamic Programming, Stack
- 2471. Minimum Amount of Time to Collect Garbage - Medium - StringYou are given a 0-indexed array of strings garbage where garbage[i] represents the assortment of garbage at the ith house. garbage[i] consists only of... Topics: Array, String, Prefix Sum
- 3202. High-Access Employees - Medium - StringYou are given a 2D 0-indexed array of strings, access_times, with size n. For each i where 0 <= i <= n - 1, access_times[i][0] represents the name of ... Topics: Array, Hash Table, String, Sorting
- 1264. Maximum Number of Words You Can Type - Easy - StringThere is a malfunctioning keyboard where some letter keys do not work. All other keys on the keyboard work properly. Given a string text of words sepa... Topics: Hash Table, String
- 3732. Calculate Score After Performing Instructions - Medium - StringYou are given two arrays, instructions and values, both of size n. You need to simulate a process based on the following rules: You start at the first... Topics: Array, Hash Table, String, Simulation
- 1850. Minimum Length of String After Deleting Similar Ends - Medium - StringGiven a string s consisting only of characters 'a', 'b', and 'c'. You are asked to apply the following algorithm on the string any number of times: Pi... Topics: Two Pointers, String
- 345. Reverse Vowels of a String - Easy - StringGiven a string s, reverse only all the vowels in the string and return it. The vowels are 'a', 'e', 'i', 'o', and 'u', and they can appear in both low... Topics: Two Pointers, String
- 1260. Day of the Year - Easy - StringGiven a string date representing a Gregorian calendar date formatted as YYYY-MM-DD, return the day number of the year.... Topics: Math, String
- 926. Find and Replace Pattern - Medium - StringGiven a list of strings words and a string pattern, return a list of words[i] that match pattern. You may return the answer in any order. A word match... Topics: Array, Hash Table, String
- 2243. Check if All A's Appears Before All B's - Easy - StringGiven a string s consisting of only the characters 'a' and 'b', return true if every 'a' appears before every 'b' in the string. Otherwise, return fal... Topics: String
- 1443. Minimum Distance to Type a Word Using Two Fingers - Hard - StringYou have a keyboard layout as shown above in the X-Y plane, where each English uppercase letter is located at some coordinate. For example, the letter... Topics: String, Dynamic Programming
- 1381. Maximum Score Words Formed by Letters - Hard - StringGiven a list of words, list of single letters (might be repeating) and score of every character. Return the maximum score of any valid set of words f... Topics: Array, String, Dynamic Programming, Backtracking, Bit Manipulation, Bitmask
- 3142. Longest Unequal Adjacent Groups Subsequence II - Medium - StringYou are given a string array words, and an array groups, both arrays having length n. The hamming distance between two strings of equal length is the ... Topics: Array, String, Dynamic Programming
- 1261. Swap For Longest Repeated Character Substring - Medium - StringYou are given a string text. You can swap two of the characters in the text. Return the length of the longest substring with repeated characters.... Topics: Hash Table, String, Sliding Window
- 677. Map Sum Pairs - Medium - StringDesign a map that allows you to do the following: Maps a string key to a given value. Returns the sum of the values that have a key with a prefix equa... Topics: Hash Table, String, Design, Trie
- 3810. Count Numbers with Non-Decreasing Digits - Hard - StringYou are given two integers, l and r, represented as strings, and an integer b. Return the count of integers in the inclusive range [l, r] whose digits... Topics: Math, String, Dynamic Programming
- 3468. Find the Encrypted String - Easy - StringYou are given a string s and an integer k. Encrypt the string using the following algorithm: For each character c in s, replace c with the kth charact... Topics: String
- 2594. Count Pairs Of Similar Strings - Easy - StringYou are given a 0-indexed string array words. Two strings are similar if they consist of the same characters. For example, "abca" and "cba" are simila... Topics: Array, Hash Table, String, Bit Manipulation, Counting
- 3408. Count the Number of Special Characters I - Easy - StringYou are given a string word. A letter is called special if it appears both in lowercase and uppercase in word. Return the number of special letters in... Topics: Hash Table, String
- 1156. Occurrences After Bigram - Easy - StringGiven two strings first and second, consider occurrences in some text of the form "first second third", where second comes immediately after first, an... Topics: String
- 2059. Unique Length-3 Palindromic Subsequences - Medium - StringGiven a string s, return the number of unique palindromes of length three that are a subsequence of s. Note that even if there are multiple ways to ob... Topics: Hash Table, String, Bit Manipulation, Prefix Sum
- 2487. Optimal Partition of String - Medium - StringGiven a string s, partition the string into one or more substrings such that the characters in each substring are unique. That is, no letter appears i... Topics: Hash Table, String, Greedy
- 3567. Convert Date to Binary - Easy - StringYou are given a string date representing a Gregorian calendar date in the yyyy-mm-dd format. date can be written in its binary representation obtained... Topics: Math, String
- 1524. String Matching in an Array - Easy - StringGiven an array of string words, return all strings in words that are a substring of another word. You can return the answer in any order.... Topics: Array, String, String Matching
- 3276. Minimum Number of Pushes to Type Word II - Medium - StringYou are given a string word containing lowercase English letters. Telephone keypads have keys mapped with distinct collections of lowercase English le... Topics: Hash Table, String, Greedy, Sorting, Counting
- 2053. Check if All Characters Have Equal Number of Occurrences - Easy - StringGiven a string s, return true if s is a good string, or false otherwise. A string s is good if all the characters that appear in s have the same numbe... Topics: Hash Table, String, Counting
- 2191. Minimum Number of Food Buckets to Feed the Hamsters - Medium - StringYou are given a 0-indexed string hamsters where hamsters[i] is either: 'H' indicating that there is a hamster at index i, or '.' indicating that index... Topics: String, Dynamic Programming, Greedy
- 2187. Vowels of All Substrings - Medium - StringGiven a string word, return the sum of the number of vowels ('a', 'e', 'i', 'o', and 'u') in every substring of word. A substring is a contiguous (non... Topics: Math, String, Dynamic Programming, Combinatorics
- 1994. Minimum Number of Swaps to Make the Binary String Alternating - Medium - StringGiven a binary string s, return the minimum number of character swaps to make it alternating, or -1 if it is impossible. The string is called alternat... Topics: String, Greedy
- 1644. Maximum Number of Non-Overlapping Substrings - Hard - StringGiven a string s of lowercase letters, you need to find the maximum number of non-empty substrings of s that meet the following conditions: The substr... Topics: String, Greedy
- 2377. Check if Number Has Equal Digit Count and Digit Value - Easy - StringYou are given a 0-indexed string num of length n consisting of digits. Return true if for every index i in the range 0 <= i < n, the digit i occurs nu... Topics: Hash Table, String, Counting
- 3800. Longest Common Prefix Between Adjacent Strings After Removals - Medium - StringYou are given an array of strings words. For each index i in the range [0, words.length - 1], perform the following steps: Remove the element at index... Topics: Array, String
- 564. Find the Closest Palindrome - Hard - StringGiven a string n representing an integer, return the closest integer (not including itself), which is a palindrome. If there is a tie, return the smal... Topics: Math, String
- 3553. Check if Two Chessboard Squares Have the Same Color - Easy - StringYou are given two strings, coordinate1 and coordinate2, representing the coordinates of a square on an 8 x 8 chessboard. Below is the chessboard for r... Topics: Math, String
- 3046. Minimum Operations to Make a Special Number - Medium - StringYou are given a 0-indexed string num representing a non-negative integer. In one operation, you can pick any digit of num and delete it. Note that if ... Topics: Math, String, Greedy, Enumeration
- 2093. Check If String Is a Prefix of Array - Easy - StringGiven a string s and an array of strings words, determine whether s is a prefix string of words. A string s is a prefix string of words if s can be ma... Topics: Array, Two Pointers, String
- 2365. Percentage of Letter in String - Easy - StringGiven a string s and a character letter, return the percentage of characters in s that equal letter rounded down to the nearest whole percent.... Topics: String
- 3570. Count of Substrings Containing Every Vowel and K Consonants I - Medium - StringYou are given a string word and a non-negative integer k. Return the total number of substrings of word that contain every vowel ('a', 'e', 'i', 'o', ... Topics: Hash Table, String, Sliding Window
- 886. Score of Parentheses - Medium - StringGiven a balanced parentheses string s, return the score of the string. The score of a balanced parentheses string is based on the following rule: "()"... Topics: String, Stack
- 2427. First Letter to Appear Twice - Easy - StringGiven a string s consisting of lowercase English letters, return the first letter to appear twice. Note: A letter a appears twice before another lette... Topics: Hash Table, String, Bit Manipulation, Counting
- 1045. Check If Word Is Valid After Substitutions - Medium - StringGiven a string s, determine if it is valid. A string s is valid if, starting with an empty string t = "", you can transform t into s after performing ... Topics: String, Stack
- 2115. Number of Unique Good Subsequences - Hard - StringYou are given a binary string binary. A subsequence of binary is considered good if it is not empty and has no leading zeros (with the exception of "0... Topics: String, Dynamic Programming
- 599. Minimum Index Sum of Two Lists - Easy - StringGiven two arrays of strings list1 and list2, find the common strings with the least index sum. A common string is a string that appeared in both list1... Topics: Array, Hash Table, String
- 3223. Count Complete Substrings - Hard - StringYou are given a string word and an integer k. A substring s of word is complete if: Each character in s occurs exactly k times. The difference between... Topics: Hash Table, String, Sliding Window
- 938. Numbers At Most N Given Digit Set - Hard - StringGiven an array of digits which is sorted in non-decreasing order. You can write numbers using each digits[i] as many times as we want. For example, if... Topics: Array, Math, String, Binary Search, Dynamic Programming
- 1967. Longest Substring Of All Vowels in Order - Medium - StringA string is considered beautiful if it satisfies the following conditions: Each of the 5 English vowels ('a', 'e', 'i', 'o', 'u') must appear at least... Topics: String, Sliding Window
- 2017. Minimum Number of Flips to Make the Binary String Alternating - Medium - StringYou are given a binary string s. You are allowed to perform two types of operations on the string in any sequence: Type-1: Remove the character at the... Topics: String, Dynamic Programming, Sliding Window
- 1652. Minimum Suffix Flips - Medium - StringYou are given a 0-indexed binary string target of length n. You have another binary string s of length n that is initially set to all zeros. You want ... Topics: String, Greedy
- 1423. Maximum Number of Occurrences of a Substring - Medium - StringGiven a string s, return the maximum number of occurrences of any substring under the following rules: The number of unique characters in the substrin... Topics: Hash Table, String, Sliding Window
- 872. Split Array into Fibonacci Sequence - Medium - StringYou are given a string of digits num, such as "123456579". We can split it into a Fibonacci-like sequence [123, 456, 579]. Formally, a Fibonacci-like ... Topics: String, Backtracking
- 482. License Key Formatting - Easy - StringYou are given a license key represented as a string s that consists of only alphanumeric characters and dashes. The string is separated into n + 1 gro... Topics: String
- 2163. Kth Distinct String in an Array - Easy - StringA distinct string is a string that is present only once in an array. Given an array of strings arr, and an integer k, return the kth distinct string p... Topics: Array, Hash Table, String, Counting
- 2285. Design Bitset - Medium - StringA Bitset is a data structure that compactly stores bits. Implement the Bitset class: Bitset(int size) Initializes the Bitset with size bits, all of wh... Topics: Array, Hash Table, String, Design
- 2275. Find Substring With Given Hash Value - Hard - StringThe hash of a 0-indexed string s of length k, given integers p and m, is computed using the following function: hash(s, p, m) = (val(s[0]) * p0 + val(... Topics: String, Sliding Window, Rolling Hash, Hash Function
- 839. Short Encoding of Words - Medium - StringA valid encoding of an array of words is any reference string s and array of indices indices such that: words.length == indices.length The reference s... Topics: Array, Hash Table, String, Trie
- 3235. Minimum Cost to Convert String I - Medium - StringYou are given two 0-indexed strings source and target, both of length n and consisting of lowercase English letters. You are also given two 0-indexed ... Topics: Array, String, Graph, Shortest Path
- 868. Push Dominoes - Medium - StringThere are n dominoes in a line, and we place each domino vertically upright. In the beginning, we simultaneously push some of the dominoes either to t... Topics: Two Pointers, String, Dynamic Programming
- 1632. Number of Good Ways to Split a String - Medium - StringYou are given a string s. A split is called good if you can split s into two non-empty strings sleft and sright where their concatenation is equal to ... Topics: Hash Table, String, Dynamic Programming, Bit Manipulation
- 3453. Generate Binary Strings Without Adjacent Zeros - Medium - StringYou are given a positive integer n. A binary string x is valid if all substrings of x of length 2 contain at least one "1". Return all valid strings w... Topics: String, Backtracking, Bit Manipulation
- 1895. Minimum Number of Operations to Move All Balls to Each Box - Medium - StringYou have n boxes. You are given a binary string boxes of length n, where boxes[i] is '0' if the ith box is empty, and '1' if it contains one ball. In ... Topics: Array, String, Prefix Sum
- 961. Long Pressed Name - Easy - StringYour friend is typing his name into a keyboard. Sometimes, when typing a character c, the key might get long pressed, and the character will be typed ... Topics: Two Pointers, String
- 1770. Minimum Deletions to Make Character Frequencies Unique - Medium - StringA string s is called good if there are no two different characters in s that have the same frequency. Given a string s, return the minimum number of c... Topics: Hash Table, String, Greedy, Sorting
- 2346. Largest 3-Same-Digit Number in String - Easy - StringYou are given a string num representing a large integer. An integer is good if it meets the following conditions: It is a substring of num with length... Topics: String
- 3812. Smallest Palindromic Rearrangement I - Medium - StringYou are given a palindromic string s. Return the lexicographically smallest palindromic permutation of s.... Topics: String, Sorting, Counting Sort
- 500. Keyboard Row - Easy - StringGiven an array of strings words, return the words that can be typed using letters of the alphabet on only one row of American keyboard like the image ... Topics: Array, Hash Table, String
- 1709. Alert Using Same Key-Card Three or More Times in a One Hour Period - Medium - StringLeetCode company workers use key-cards to unlock office doors. Each time a worker uses their key-card, the security system saves the worker's name and... Topics: Array, Hash Table, String, Sorting
- 841. Shortest Distance to a Character - Easy - StringGiven a string s and a character c that occurs in s, return an array of integers answer where answer.length == s.length and answer[i] is the distance ... Topics: Array, Two Pointers, String
- 1093. Recover a Tree From Preorder Traversal - Hard - StringWe run a preorder depth-first search (DFS) on the root of a binary tree. At each node in this traversal, we output D dashes (where D is the depth of t... Topics: String, Tree, Depth-First Search, Binary Tree
- 2244. Number of Laser Beams in a Bank - Medium - StringAnti-theft security devices are activated inside a bank. You are given a 0-indexed binary string array bank representing the floor plan of the bank, w... Topics: Array, Math, String, Matrix
- 3305. Count Prefix and Suffix Pairs II - Hard - StringYou are given a 0-indexed string array words. Let's define a boolean function isPrefixAndSuffix that takes two strings, str1 and str2: isPrefixAndSuff... Topics: Array, String, Trie, Rolling Hash, String Matching, Hash Function
- 2168. Check if Numbers Are Ascending in a Sentence - Easy - StringA sentence is a list of tokens separated by a single space with no leading or trailing spaces. Every token is either a positive number consisting of d... Topics: String
- 1818. Maximum Score From Removing Substrings - Medium - StringYou are given a string s and two integers x and y. You can perform two types of operations any number of times. Remove substring "ab" and gain x point... Topics: String, Stack, Greedy
- 1542. Consecutive Characters - Easy - StringThe power of the string is the maximum length of a non-empty substring that contains only one unique character. Given a string s, return the power of ... Topics: String
- 730. Count Different Palindromic Subsequences - Hard - StringGiven a string s, return the number of different non-empty palindromic subsequences in s. Since the answer may be very large, return it modulo 109 + 7... Topics: String, Dynamic Programming
- 2130. Maximum Product of the Length of Two Palindromic Subsequences - Medium - StringGiven a string s, find two disjoint palindromic subsequences of s such that the product of their lengths is maximized. The two subsequences are disjoi... Topics: String, Dynamic Programming, Backtracking, Bit Manipulation, Bitmask
- 2341. Count Prefixes of a Given String - Easy - StringYou are given a string array words and a string s, where words[i] and s comprise only of lowercase English letters. Return the number of strings in wo... Topics: Array, String
- 824. Number of Lines To Write String - Easy - StringYou are given a string s of lowercase English letters and an array widths denoting how many pixels wide each lowercase English letter is. Specifically... Topics: Array, String
- 1159. Smallest Subsequence of Distinct Characters - Medium - StringGiven a string s, return the lexicographically smallest subsequence of s that contains all the distinct characters of s exactly once.... Topics: String, Stack, Greedy, Monotonic Stack
- 3629. Total Characters in String After Transformations I - Medium - StringYou are given a string s and an integer t, representing the number of transformations to perform. In one transformation, every character in s is repla... Topics: Hash Table, Math, String, Dynamic Programming, Counting
- 472. Concatenated Words - Hard - StringGiven an array of strings words (without duplicates), return all the concatenated words in the given list of words. A concatenated word is defined as ... Topics: Array, String, Dynamic Programming, Depth-First Search, Trie, Sorting
- 1252. Break a Palindrome - Medium - StringGiven a palindromic string of lowercase English letters palindrome, replace exactly one character with any lowercase English letter so that the result... Topics: String, Greedy
- 2886. Faulty Keyboard - Easy - StringYour laptop keyboard is faulty, and whenever you type a character 'i' on it, it reverses the string that you have written. Typing other characters wor... Topics: String, Simulation
- 1133. Last Substring in Lexicographical Order - Hard - StringGiven a string s, return the last substring of s in lexicographical order.... Topics: Two Pointers, String
- 974. Reorder Data in Log Files - Medium - StringYou are given an array of logs. Each log is a space-delimited string of words, where the first word is the identifier. There are two types of logs: Le... Topics: Array, String, Sorting
- 1999. Longer Contiguous Segments of Ones than Zeros - Easy - StringGiven a binary string s, return true if the longest contiguous segment of 1's is strictly longer than the longest contiguous segment of 0's in s, or r... Topics: String
- 2107. Find Unique Binary String - Medium - StringGiven an array of strings nums containing n unique binary strings each of length n, return a binary string of length n that does not appear in nums. I... Topics: Array, Hash Table, String, Backtracking
- 973. Stamping The Sequence - Hard - StringYou are given two strings stamp and target. Initially, there is a string s of length target.length with all s[i] == '?'. In one turn, you can place st... Topics: String, Stack, Greedy, Queue
- 889. Buddy Strings - Easy - StringGiven 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 i... Topics: Hash Table, String
- 2157. Smallest K-Length Subsequence With Occurrences of a Letter - Hard - StringYou are given a string s, an integer k, a letter letter, and an integer repetition. Return the lexicographically smallest subsequence of s of length k... Topics: String, Stack, Greedy, Monotonic Stack
- 3706. Smallest Substring With Identical Characters II - Hard - StringYou are given a binary string s of length n and an integer numOps. You are allowed to perform the following operation on s at most numOps times: Selec... Topics: String, Binary Search
- 2414. Move Pieces to Obtain a String - Medium - StringYou are given two strings start and target, both of length n. Each string consists only of the characters 'L', 'R', and '_' where: The characters 'L' ... Topics: Two Pointers, String
- 2691. Count Vowel Strings in Ranges - Medium - StringYou are given a 0-indexed array of strings words and a 2D array of integers queries. Each query queries[i] = [li, ri] asks us to find the number of st... Topics: Array, String, Prefix Sum
- 1812. Reformat Phone Number - Easy - StringYou are given a phone number as a string number. number consists of digits, spaces ' ', and/or dashes '-'. You would like to reformat the phone number... Topics: String
- 1483. Rank Teams by Votes - Medium - StringIn a special ranking system, each voter gives a rank from highest to lowest to all teams participating in the competition. The ordering of teams is de... Topics: Array, Hash Table, String, Sorting, Counting
- 1751. Slowest Key - Easy - StringA newly designed keypad was tested, where a tester pressed a sequence of n keys, one at a time. You are given a string keysPressed of length n, where ... Topics: Array, String
- 606. Construct String from Binary Tree - Medium - StringGiven the root node of a binary tree, your task is to create a string representation of the tree following a specific set of formatting rules. The rep... Topics: String, Tree, Depth-First Search, Binary Tree
- 2492. Length of the Longest Alphabetical Continuous Substring - Medium - StringAn alphabetical continuous string is a string consisting of consecutive letters in the alphabet. In other words, it is any substring of the string "ab... Topics: String
- 1804. Maximum Binary String After Change - Medium - StringYou are given a binary string binary consisting of only 0's or 1's. You can apply each of the following operations any number of times: Operation 1: I... Topics: String, Greedy
- 1954. Replace All Digits with Characters - Easy - StringYou are given a 0-indexed string s that has lowercase English letters in its even indices and digits in its odd indices. You must perform an operation... Topics: String
- 855. Count Unique Characters of All Substrings of a Given String - Hard - StringLet's define a function countUniqueChars(s) that returns the number of unique characters in s. For example, calling countUniqueChars(s) if s = "LEETCO... Topics: Hash Table, String, Dynamic Programming
- 3631. Count K-Reducible Numbers Less Than N - Hard - StringYou are given a binary string s representing a number n in its binary form. You are also given an integer k. An integer x is called k-reducible if per... Topics: Math, String, Dynamic Programming, Combinatorics
- 3487. Find Maximum Removals From Source String - Medium - StringYou are given a string source of size n, a string pattern that is a subsequence of source, and a sorted integer array targetIndices that contains dist... Topics: Array, Hash Table, Two Pointers, String, Dynamic Programming
- 1012. Equal Rational Numbers - Hard - StringGiven two strings s and t, each of which represents a non-negative rational number, return true if and only if they represent the same number. The str... Topics: Math, String
- 2190. Count Common Words With One Occurrence - Easy - StringGiven two string arrays words1 and words2, return the number of strings that appear exactly once in each of the two arrays.... Topics: Array, Hash Table, String, Counting
- 2543. Most Popular Video Creator - Medium - StringYou are given two string arrays creators and ids, and an integer array views, all of length n. The ith video on a platform was created by creators[i],... Topics: Array, Hash Table, String, Sorting, Heap (Priority Queue)
Related LeetCode Topics
- Array LeetCode Problems
- Backtracking LeetCode Problems
- Biconnected Component LeetCode Problems
- Binary Indexed Tree LeetCode Problems
- Binary Search LeetCode Problems
- Binary Search Tree LeetCode Problems
- Binary Tree LeetCode Problems
- Bit Manipulation LeetCode Problems
- Bitmask LeetCode Problems
- Brainteaser LeetCode Problems
- Breadth-First Search LeetCode Problems
- Bucket Sort LeetCode Problems
- Combinatorics LeetCode Problems
- Concurrency LeetCode Problems
- Counting LeetCode Problems
- Counting Sort LeetCode Problems
- Data Stream LeetCode Problems
- Database LeetCode Problems
- Depth-First Search LeetCode Problems
- Design LeetCode Problems