Word Pattern 1 Problem

Problem Given 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 pattern and a non-empty word in s. Examples Example 1: Input: pattern = "abba", s = "dog cat cat dog" Output: true Example 2: ...

String Compression Problem

Problem Given an array of characters chars, compress it using the following algorithm: Begin with an empty string s. For each group of consecutive repeating characters in chars: If the group’s length is 1, append the character to s. Otherwise, append the character followed by the group’s length. The compressed string s should not be returned separately, but instead, be stored in the input character array chars. Note that group lengths that are 10 or longer will be split into multiple characters in chars. ...

Valid Anagram Problem

Problem Given two strings s and t, return true if t is an anagram of s, and false otherwise. OR WAP to find out if 2 strings are anagrams or not. Anagram Definition Examples Example 1: Input: s = "anagram", t = "nagaram" Output: true Example 2: Input: s = "rat", t = "car" Output: false ...

Regular Expression Matching Problem

Problem Given an input string s and a pattern p, implement regular expression matching with support for '.' and '*' where: '.' Matches any single character. '*' Matches zero or more of the preceding element. The matching should cover the entire input string (not partial). Examples Some examples: isMatch("aa","a") ? false isMatch("aa","a.") ? true isMatch("aaa","ab*") ? false isMatch("aa", ".*") ? true isMatch("aa", "a*") ? true isMatch("ab", ".*") ? true isMatch("aabaa", "a*b.*") ? false ...

Wildcard Matching Problem

Problem Given an input string (s) and a pattern (p), implement wildcard pattern matching with support for '?' and '*' where: '?' Matches any single character. '*' Matches any sequence of characters (including the empty sequence). The matching should cover the entire input string (not partial). Examples Example 1: Input: s = "aa", p = "a" Output: false Explanation: "a" does not match the entire string "aa". ...

Isomorphic Strings Problem

Problem Given two strings s and t, determine if they are isomorphic. Definition Two strings s and t are isomorphic if the characters in s can be replaced to get t. All occurrences of a character must be replaced with another character while preserving the order of characters. No two characters may map to the same character, but a character may map to itself. Example Example 1: ...

Unique Email Addresses Problem

Problem Every 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 '.' or '+'. For example, in "[email protected]", "alice" is the local name, and "leetcode.com" is the domain name. If you add periods '.' between some characters in the local name part of an email address, mail sent there will be forwarded to the same address without dots in the local name. Note that this rule does not apply to domain names. ...

Generate All Strings of n bits

Problem Generate All Strings of n bits, consider A[0..n-1] is an array of size n. Examples Example 1 n = 3 Output: [0, 0, 0] [1, 0, 0] [0, 1, 0] [1, 1, 0] [0, 0, 1] [1, 0, 1] [0, 1, 1] [1, 1, 1] ...

ZigZag Conversion Problem

Problem The 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 for better legibility) P A H N A P L S I I G Y I R ...

Minimum Remove to Make Valid Parentheses

Problem Given a string s of '(' , ')' and lowercase English characters. Your task is to remove the minimum number of parentheses ( '(' or ')', in any positions ) so that the resulting parentheses string is valid and return any valid string. Formally, a parentheses string is valid if and only if: It is the empty string, contains only lowercase characters, or It can be written as AB (A concatenated with B), where A and B are valid strings, or It can be written as (A), where A is a valid string. Examples Example 1: ...

This site uses cookies to improve your experience on our website. By using and continuing to navigate this website, you accept this. Privacy Policy