LeetCode
LeetCode 196: Delete Duplicate Emails
·2 mins
LeetCode
Easy
Database
LeetCode 196 note: it must be a DELETE, not a SELECT; keep only the smallest id per email and delete the rest
LeetCode 183: Customers Who Never Order
·1 min
LeetCode
Easy
Database
LeetCode 183 note: LEFT JOIN Orders, and customers with no matching order (o.id IS NULL) never ordered; NOT IN also works
LeetCode 182: Duplicate Emails
·1 min
LeetCode
Easy
Database
LeetCode 182 note: group by email and keep groups with HAVING COUNT(*) > 1
LeetCode 181: Employees Earning More Than Their Managers
·1 min
LeetCode
Easy
Database
LeetCode 181 note: self-join Employee on managerId = id to pair employees with managers, then compare salaries
LeetCode 175: Combine Two Tables
·1 min
LeetCode
Easy
Database
LeetCode 175 note: people without an address must still appear, so LEFT JOIN, leaving city and state NULL when unmatched
LeetCode 26: Remove Duplicates from Sorted Array
·2 mins
LeetCode
Easy
Array
Two-Pointers
LeetCode 26 note: overwrite in place with a write pointer for the next slot, writing only values different from the last one written
LeetCode 14: Longest Common Prefix
·2 mins
LeetCode
Easy
Array
String
Trie
LeetCode 14 note: bound by the shortest string and check each position across all strings; the first mismatch gives the answer’s length
LeetCode 13: Roman to Integer
·1 min
LeetCode
Easy
Hash-Table
Math
String
LeetCode 13 note: add each symbol’s value left to right, subtracting instead when it is smaller than the symbol to its right
LeetCode 9: Palindrome Number
·2 mins
LeetCode
Easy
Math
LeetCode 9 note: negatives are never palindromes; without strings, reverse the second half of the digits and compare it with the first half
LeetCode 7: Reverse Integer
·2 mins
LeetCode
Medium
Math
LeetCode 7 note: remember the sign, reverse the digits of the absolute value, and return 0 when the result leaves the signed 32-bit range
LeetCode 1: Two Sum
·2 mins
LeetCode
Easy
Array
Hash-Table
LeetCode 1 note: store seen numbers in a hash map while scanning and look up target - x; checking before storing prevents using one element twice