ZHR Blog

For those who fight for it, life has a flavor the sheltered will never know

Counts Vowels Permutation

Leetcode Daily Challenge

Problem Given an integer n, your task is to count how many strings of length n can be formed under the following rules: Each character is a lower case vowel (‘a’, ‘e’, ‘i’, ‘o’, ‘u’) Each vowel ‘...

Find K Closet Elements

Leetcode Daily Challenge

Problem Given a sorted integer array arr, two integers k and x, return the k closest integers to x in the array. The result should also be sorted in ascending order. An integer a is closer to x t...

Find Leaves of Binary Tree

Leetcode Daily Challenge

Problem Given the root of a binary tree, collect a tree’s nodes as if you were doing this: Collect all the leaf nodes. Remove all the leaf nodes. Repeat until the tree is empty. The number of no...

Palindrome Pairs

Leetcode June Challenge

Palindrome Pairs (June 13th) Given a list of unique words, return all the pairs of the distinct indices (i, j) in the given list, so that the concatenation of the two words words[i] + words[j] ...

Contact Tracing to Fight COVID

Using Bluetooth Protocol

Contact Tracing to Fight COVID Today I watched a great video by Hussein Nasser, which talks about a bluetooth protocol proposed by Google and Apple to trace contact during COVID. For this problem...

Serialize and Deserialize Tree

Problem Description Write a serialize function and deserialize function to convert a tree to a string and a string to a tree Solution This is a very interesting problem. For a long time, I thought...

Path Sum III

LeetCode 437

Problem Leetcode 437 You are given a binary tree in which each node contains an integer value. Find the number of paths that sum to a given value. The path does not need to start or end at the r...

Valid Sodoku

LeetCode 36

This is a very interesting question. At first glance, it appears to be a hard question. I guess it’s because all the terribble memory of trying to solve a soduku on airplane. But essentially this i...

Rotate Image

LeetCode 48

This is a classical algorithm question. The problem askes us to rotate the matrix by 90 degrees. The important thing to realize here is what rotating means. Here rotating means, the first row will ...

My First Post

Hello World, Hello Blog

Hello World!