PROBLEM DESCRIPTION A set of real numbers can be represented as the union of several disjoint intervals, where each interval is in the form [a, b). A real number x is in the set if one of its inte...
Add Bold Tag in String
PROBLEM DESCRIPTION You are given a string s and an array of strings words. You should add a closed pair of bold tag <b> and </b> to wrap the substrings in s that exist in words. ...
Missing Ranges
PROBLEM DESCRIPTION You are given an inclusive range [lower, upper] and a sorted unique integer array nums, where all elements are within the inclusive range. A number x is considered missing if ...
Candy Crush
PROBLEM DESCRIPTION Given an m x n integer array board representing the grid of candy where board[i][j] represents the type of candy. A value of board[i][j] == 0 represents that the cell is empty....
Sparse Matrix Multiplication
PROBLEM DESCRIPTION Given two sparse matrices mat1 of size m x k and mat2 of size k x n, return the result of mat1 x mat2. You may assume that multiplication is always possible. leetcode SOLUTION...
Group Shifted Strings
PROBLEM DESCRIPTION Given a string s and an integer k, return the number of substrings in s of length k with no repeated characters. leetcode SOLUTION We find how many shifts it would take i...
Find K-Length Substrings With No Repeated Characters
PROBLEM DESCRIPTION Given a string s and an integer k, return the number of substrings in s of length k with no repeated characters. leetcode SOLUTION class Solution { public int numKLenSu...
Max Consecutive Ones II
PROBLEM DESCRIPTION Given a binary array nums, return the maximum number of consecutive 1’s in the array if you can flip at most one 0. leetcode SOLUTION class Solution { public int findMa...
Longest Substring with At Most Two Distinct Characters
PROBLEM DESCRIPTION Given a string s, return the length of the longest substring that contains at most two distinct characters. leetcode SOLUTION class Solution { public int lengthOfLonges...
Shortest Way to Form String
PROBLEM DESCRIPTION A subsequence of a string is a new string that is formed from the original string by deleting some (can be none) of the characters without disturbing the relative positions of ...