Skip to content
Home » Hash Table

Hash Table

Leetcode 202. Happy Number

We use a map the keep records of all the numbers during the process. If at any time the converted number equals to 1 we return true directly, otherwise if the number appeared earlier we return false instead. Solution

Leetcode 48 Rotate Image

This is an interesting problem which looks complex but essentially there are just 2 steps we need to do this. Solution Javascript: Time Complexity:O(n^2) since we visited all the cells in the matrix Space Complexity:O(1) since it’s in place

Leetcode 54 Spiral Matrix

This is indeed a very interesting problem. If we simulate the process, there are a couple of key points to notice: Solution Javascript: Time Complexity:O(m*n) since we visited all the cells in the matrix Space Complexity:O(1)

Leetcode 36. Valid Sudoku

Problem Statement Determine if a 9 x 9 Sudoku board is valid. Only the filled cells need to be validated according to the following rules: Note: Examples Constraints Solution Python: Java: