Skip to content

Instantly share code, notes, and snippets.

View visionbyangelic's full-sized avatar
💭
Probably Studying

Angelic visionbyangelic

💭
Probably Studying
View GitHub Profile

242 | Valid Anagram 🔄 - Leetcode Day 3

The Challenge: 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.)

💡 The "Aha!" Moment

I initially thought about just checking if every letter in s existed in t. But I realized that fails for words with duplicate letters (like "Apple" vs "Pale"). Just knowing a letter exists isn't enough; I needed to know how many times it appears. I needed a full inventory, not just a guest list.

🛠️ My Strategy: The "Inventory Check"

217 | Contains Duplicate 👯‍♂️ - Leetcode Day 2

The Challenge: Given an integer array nums, return true if any value appears at least twice in the array, and return false if every element is distinct.

💡 The "Aha!" Moment

Initially, I thought about comparing every number against every other number (Brute Force), but that is too slow for large lists. I realized I didn't need to check everyone against everyone; I just needed a way to remember what I had already seen. If I see a number that is already in my "memory," I know immediately it is a duplicate.

🛠️ My Strategy: The "Bouncer" Set

001 | Two Sum 🎯

The Challenge: Find two numbers in a list that add up to a specific target.


💡 The "Aha!" Moment

Initially, I thought about checking every single pair (which is slow). Then I realized: if I'm looking at a number like 7 and the target is 10, I am essentially hunting for a 3. Instead of looking forward, I can keep a "memory" of what I've already seen to find that 3 instantly.

🛠️ My Strategy: The "Memory" Map

@nerdyalgorithm
nerdyalgorithm / leetcode-2942-find-words-containing.md
Created August 5, 2025 19:38
leetcode-2942-find words containing character

🧠 Approach

Given a list of words and a character x, we need to return the indices of the words that contain that character.

I used a basic loop with enumerate() to track both the index and the word. If the character x is found in the word (if x in word:), I store the index.