Skip to main content

Posts

Leetcode 44: Wildcard Matching

  1. Problem Statement (Simple Explanation): You’re given: A string s (text). A pattern p that may contain: lowercase letters '?' which matches  any single character '*' which matches  any sequence of characters  (including empty) You must determine if  the entire string s  matches  the entire pattern p  (no partial match). 2. Examples: Example 1: Input: s = "aa", p = "a" Pattern "a" is only one character; s has two characters → cannot match entire string. Output: false Example 2: Input: s = "aa", p = "*" '*' can match any sequence, including "aa". Output: true Example 3: Input: s = "cb", p = "?a" '?' matches 'c' 'a' must match 'b' → mismatch Output: false Constraints: 0 <= s.length, p.length <= 2000 s has only lowercase letters. p has lowercase letters, '?', '*'. 3. Approaches Overview: Common approaches: Greedy with back...
Recent posts

Leetcode 43: Multiply Strings

1. Problem Statement (Simple Explanation): You’re given two  non-negative integers  num1 and num2 as  strings . You must: Return their product as a  string . You  cannot : Use built-in big integer libraries. Convert the entire strings directly to integers. Lengths: 1 <= len(num1), len(num2) <= 200 Digits only, no leading zero except "0" itself. 2. Examples: Example 1: Input: num1 = "2", num2 = "3" 2 * 3 = 6 Output: "6" Example 2: Input: num1 = "123", num2 = "456" 123 * 456 = 56088 Output: "56088" 3. Intuition – Simulate Grade-School Multiplication: We multiply like on paper: For num1 = "123", num2 = "456":    1 2 3 x    4 5 6 ---------      7 3 8   (123 * 6, shifted by 0)    6 1 5     (123 * 5, shifted by 1)  4 9 2       (123 * 4, shifted by 2) ---------  5 6 0 8 8 But instead of summing separate rows, we can direct...