Algorithem
Algorithem_Matrix
题目 Given an m x n binary matrix mat, return the distance of the nearest 0 for each cell.
The distance between two adjacent cells is 1.
Ex…
Algorithem_PermutationInString
Given two strings s1 and s2, return true if s2 contains a permutation of s1, or false otherwise. In other words, return true if one of s1's…
Algorithem_ReverseLinkedList
Given the head of a singly linked list, reverse the list, and return the reversed list. Given the head of a singly linked list, reverse…
Algorithem_MergeTwoSortedLists
You are given the heads of two sorted linked lists list1 and list2. Merge the two lists in a one sorted list. The list should be made by…
Algorithem_Merge Two Binary Trees
You are given two binary trees root1 and root2. Imagine that when you put one of them to cover the other, some nodes of the two trees are…
Algorithem_Populating Next Right Pointers in Each Node
You are given a perfect binary tree where all leaves are on the same level, and every parent has two children. The binary tree has the…
Algorithem_Max Area of Island
You are given an m x n binary matrix grid. An island is a group of 1's (representing land) connected 4-directionally (horizontal or…
Algorithem_TwoPointersOfLinked List
876. Middle of the Linked List Given the head of a singly linked list, return the middle node of the linked list.
If there are two middle…
Algorithem_TwoPointers
Two Sum II - Input Array Is Sorted Given a 1-indexed array of integers numbers that is already sorted in non-decreasing order, find two…
Algorithem_ReverseWords
Reverse Words in a String III Given a string s, reverse the order of characters in each word within a sentence while still preserving…
Algorithem_MoveZeros
Given an integer array nums, move all 0's to the end of it while maintaining the relative order of the non-zero elements. Note that you…
Algorithem_ReverseArray
Given an array, rotate the array to the right by k steps, where k is non-negative. Example 1:
Copy
Input: nums = [1,2,3,4,5,6,7], k = 3…
Algorithem_Sort
Given an integer array nums sorted in non-decreasing order, return an array of the squares of each number sorted in non-decreasing order.…
Algorithem_BinarySearch
BinarySearch Given an array of integers nums which is sorted in ascending order, and an integer target, write a function to search target…