## Leetcode 242: Valid Anagram

Problem Statement Given two strings s and t, return true if t is an anagram of s, and false otherwise. An Anagram is a word or phrase formed by rearranging the letters of a different word or phrase, typically using all the original letters exactly once. Example 1: Input: s = "anagram", t = "nagaram" Output: true Example 2: Input: s = "rat", t = "car" Output: false Solution Python Implementation from collections import Counter class Solution: def isAnagram(self, s: str, t: str) -> bool: """ T: O(N) = max(S + T) S: O(N) """ s_mp = Counter(s) t_mp = Counter(t) return s_mp == t_mp Leetcode 242: Valid Anagram

January 10, 2023 · 1 min · 109 words · Me

## Leetcode 125: Valid Palindrome

Problem Statement A phrase is a palindrome if, after converting all uppercase letters into lowercase letters and removing all non-alphanumeric characters, it reads the same forward and backward. Alphanumeric characters include letters and numbers. Given a string s, return true if it is a palindrome, or false otherwise. Example 1: Input: s = "A man, a plan, a canal: Panama" Output: true Explanation: "amanaplanacanalpanama" is a palindrome. Example 2: Input: s = "race a car" Output: false Explanation: "raceacar" is not a palindrome....

January 10, 2023 · 2 min · 217 words · Me

## Leetcode 21: Merge Two Sorted Lists

Problem Statement You are given the heads of two sorted linked lists list1 and list2. Merge the two lists in a one sorted list. The list should be made by splicing together the nodes of the first two lists. Return the head of the merged linked list. Example 1: """ 1-->2-->4-->5 ^list1 1-->3-->4 ^list2 1-->1-->2-->3-->4-->4-->5 ^curr """ Input: list1 = [1,2,4,5], list2 = [1,3,4] Output: [1,1,2,3,4,4,5] Example 2: Input: list1 = [], list2 = [] Output: [] Example 3: Input: list1 = [], list2 = [0] Output: [0] Solution Intuition & Patterns In order to keep track of the head of the merged list, we will create a dummy node which will function as a pre-head node....

January 10, 2023 · 2 min · 302 words · Me

## Leetcode 20: Valid Parentheses

Problem Statement Given a string s containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. An input string is valid if: Open brackets must be closed by the same type of brackets. Open brackets must be closed in the correct order. Every close bracket has a corresponding open bracket of the same type. Example 1: Input: s = "()" Output: true Example 2: Input: s = "()[]{}" Output: true Example 3: Input: s = "(]" Output: false Solution Intuition & Patterns Leetcode #20, Valid Parentheses, is a great introduction to LIFO (last in first out) stack problems....

January 10, 2023 · 3 min · 438 words · Me

## Leetcode 57 Insert Interval

Introduction Sebastian (🧔🏼) and Carl (👨) been working through the Grind 75 to prepare for their upcoming interviews at MAANG. Back in university they made a great team and they believe that they can nail their coding interview prep by explaining their Leetcode solutions to each other. Sebastian meets with Carl at the hip little coffee show down on 8th street for their bi-weekly group study session. 🧔🏼 “I’ll start off with Leetcode 57, the insert interval problem....

January 7, 2023 · 5 min · 1029 words · Me