ZHR Blog

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

Find Peak Element

Leetcode Daily Challenge

Problem A peak element is an element that is strictly greater than its neighbors. Given an integer array nums, find a peak element, and return its index. If the array contains multiple peaks, retu...

Isomorphic Strings

Leetcode Daily Challenge

Problem Given two strings s and t, determine if they are isomorphic. Two strings s and t are isomorphic if the characters in s can be replaced to get t. All occurrences of a character must be rep...

Find Median from Data Stream

Leetcode Daily Challenge

Problem The median is the middle value in an ordered integer list. If the size of the list is even, there is no middle value and the median is the mean of the two middle values. For example, for a...

Decode way II

Leetcode Daily Challenge

Problem A message containing letters from A-Z can be encoded into numbers using the following mapping: ‘A’ -> “1” ‘B’ -> “2” … ‘Z’ -> “26” To decode an encoded message, all the digits mus...

Longest Increasing Subsequence

Leetcode Daily Challenge

Problem Given an integer array nums, return the length of the longest strictly increasing subsequence. A subsequence is a sequence that can be derived from an array by deleting some or no elements...

Reverse Words in a String II

Leetcode Daily Challenge

Problem Given a character array s, reverse the order of the words. A word is defined as a sequence of non-space characters. The words in s will be separated by a single space. Your code must solv...

Maximum Length of Repeated Subarray

Leetcode Daily Challenge

Problem Given two integer arrays nums1 and nums2, return the maximum length of a subarray that appears in both arrays. Constraints 1 <= nums1.length, nums2.length <= 1000 0 <= nums1[i], ...

kth Smallest Element in a Sorted Matrix

Leetcode Daily Challenge

Problem Given an n x n matrix where each of the rows and columns are sorted in ascending order, return the kth smallest element in the matrix. Note that it is the kth smallest element in the sorte...

Reduce Array Size to The Half

Leetcode Daily Challenge

Problem Given an array arr. You can choose a set of integers and remove all the occurrences of these integers in the array. Return the minimum size of the set so that at least half of the integer...

Reshape the Matrix

Leetcode Daily Challenge

Problem In MATLAB, there is a handy function called reshape which can reshape an m x n matrix into a new one with a different size r x c keeping its original data. You are given an m x n matrix m...