633. Sum of Square Numbers

Sum of Square Numbers Difficulty: Medium Topics: Math, Two Pointers, Binary Search Given a non-negative integer c, decide whether there’re two integers a and b such that a2 + b2 = c. Example 1: Input: c = 5 Output: true Explanation: 1 1 + 2 2 = 5 Example 2: Input: c = 3 Output: […]
632. Smallest Range Covering Elements from K Lists

Smallest Range Covering Elements from K Lists Difficulty: Hard Topics: Array, Hash Table, Greedy, Sliding Window, Sorting, Heap (Priority Queue) You have k lists of sorted integers in non-decreasing order. Find the smallest range that includes at least one number from each of the k lists. We define the range [a, b] is smaller than […]
624. Maximum Distance in Arrays

Maximum Distance in Arrays Difficulty: Medium Topics: Array, Greedy You are given m arrays, where each array is sorted in ascending order. You can pick up two integers from two different arrays (each array picks one) and calculate the distance. We define the distance between two integers a and b to be their absolute difference […]
623. Add One Row to Tree Leetcode Solution

Add One Row to Tree Leetcode Solution Difficulty: Medium Topics: Tree, Depth-First Search, Breadth-First Search, Binary Tree Given the root of a binary tree and two integers val and depth, add a row of nodes with value val at the given depth depth. Note that the root node is at depth 1. The adding rule […]
592. Fraction Addition and Subtraction

Fraction Addition and Subtraction Difficulty: Medium Topics: Math, String, Simulation Given a string expression representing an expression of fraction addition and subtraction, return the calculation result in string format. The final result should be an irreducible fraction. If your final result is an integer, change it to the format of a fraction that has a […]
590. N-ary Tree Postorder Traversal

N-ary Tree Postorder Traversa Difficulty: Easy Topics: Stack, Tree, Depth-First Search Given the root of an n-ary tree, return the postorder traversal of its nodes’ values. Nary-Tree input serialization is represented in their level order traversal. Each group of children is separated by the null value (See examples) Example 1: Input: root = [1,null,3,2,4,null,5,6] Output: […]
567. Permutation in String

Permutation in String Difficulty: Medium Topics: Hash Table, Two Pointers, String, Sliding Window Given two strings s1 and s2, return true if s2 contains a permutation[^1] of s1, or false otherwise. In other words, return true if one of s1‘s permutations is the substring of s2. Example 1: Input: s1 = “ab”, s2 = “eidbaooo” […]
564 Find the Closest Palindrome

Find the Closest Palindrome Difficulty: Hard Topics: Math, String What is Palindrome? A palindrome is a word, sentence, verse, or even number that reads the same backward or forward. Given a string n representing an integer, return _the closest integer (not including itself), which is a palindrome-. If there is a tie, return the […]
552 Student Attendance Record II

Student Attendance Record II Difficulty: Hard Topics: Dynamic Programming An attendance record for a student can be represented as a string where each character signifies whether the student was absent, late, or present on that day. The record only contains the following three characters: 'A': Absent. 'L': Late. 'P': Present. Any student is eligible for […]
539. Minimum Time Difference Leetcode Solution

Minimum Time Difference Difficulty: Medium Topics: Array, Math, String, Sorting Given a list of 24-hour clock time points in “HH:MM” format, return the minimum minutes difference between any two time-points in the list. Example 1: Input: timePoints = [“23:59″,”00:00”] Output: 1 Example 2: Input: timePoints = [“00:00″,”23:59″,”00:00”] Output: 0 Constraints: <code>2 <= timePoints.length <= 2 […]