ZHR Blog

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

sort characters by frequency

Leetcode Daily Challenge

Problem Given a string s, sort it in decreasing order based on the frequency of the characters. The frequency of a character is the number of times it appears in the string. Return the sorted stri...

jump game

Leetcode Daily Challenge

Problem You are given an integer array nums. You are initially positioned at the array’s first index, and each element in the array represents your maximum jump length at that position. Return tru...

island perimeter

Leetcode Daily Challenge

Problem You are given row x col grid representing a map where grid[i][j] = 1 represents land and grid[i][j] = 0 represents water. Grid cells are connected horizontally/vertically (not diagonally)....

Maximum Profit in Job Scheduling

Leetcode Daily Challenge

Problem We have n jobs, where every job is scheduled to be done from startTime[i] to endTime[i], obtaining a profit of profit[i]. You’re given the startTime, endTime and profit arrays, return the ...

Subsets II

Leetcode Daily Challenge

Problem Given an integer array nums that may contain duplicates, return all possible subsets (the power set). The solution set must not contain duplicate subsets. Return the solution in any order....

Make A Large Island

Leetcode Daily Challenge

Problem You are given an n x n binary matrix grid. You are allowed to change at most one 0 to be 1. Return the size of the largest island in grid after applying this operation. An island is a 4-d...

Convert Sorted Array to Binary Search Tree

Leetcode Daily Challenge

Problem Given an integer array nums where the elements are sorted in ascending order, convert it to a height-balanced binary search tree. A height-balanced binary tree is a binary tree in which th...

Word Ladder II

Leetcode Daily Challenge

Problem A transformation sequence from word beginWord to word endWord using a dictionary wordList is a sequence of words beginWord -> s1 -> s2 -> … -> sk such that: Every adjacent pair...

Alien Dictionary

Leetcode Daily Challenge

Problem There is a new alien language that uses the English alphabet. However, the order among the letters is unknown to you. You are given a list of strings words from the alien language’s dictio...

Binary Tree Pruning

Leetcode Daily Challenge

Problem Given the root of a binary tree, return the same tree where every subtree (of the given tree) not containing a 1 has been removed. A subtree of a node node is node plus every node that is ...