原创 [LeetCode281]Zigzag Iterator

Given two 1d vectors, implement an iterator to return their elements alternately. For example, given two 1d vector

原创 [LeetCode269]Alien Dictionary

There is a new alien language which uses the latin alphabet. However, the order among letters are unknown to you. Y

原创 [LeetCode285]Inorder Successor in BST

Given a binary search tree and a node in it, find the in-order successor of that node in the BST. Note: If the giv

原创 [LeetCode251]Flatten 2D Vector

Implement an iterator to flatten a 2d vector. For example, Given 2d vector = [ [1,2], [3], [4,5,6] ] By cal

原创 [LeetCode266]Palindrome Permutation

Given a string, determine if a permutation of the string could form a palindrome. For example, "code" -> False, "a

原创 [LeetCode325] Maximum Size Subarray Sum Equals k

Given an array nums and a target value k, find the maximum length of a subarray that sums to k. If there isn't one, ret

原创 [LeetCode291]Word Pattern II

Given a pattern and a string str, find if str follows the same pattern. Here follow means a full match, such that ther

原创 [LeetCode164]Maximum Gap

HARD Given an unsorted array, find the maximum difference between the successive elements in its sorted form. Try to s

原创 [LeetCode315] Count of Smaller Numbers After Self

You are given an integer array nums and you have to return a new counts array. The counts array has the property where

原创 [LeetCode222]Count Complete Tree Nodes

Given a complete binary tree, count the number of nodes. Definition of a complete binary tree from Wikipedia: In a com

原创 [LeetCode317]Shortest Distance from All Buildings

You want to build a house on an empty land which reaches all buildings in the shortest amount of distance. You are give

原创 [LeetCode314]Binary Tree Vertical Order Traversal

Given a binary tree, return the vertical order traversal of its nodes' values. (ie, from top to bottom, column by colum

原创 [LeetCode311]Sparse Matrix Multiplication

Given two sparse matrices A and B, return the result of AB. You may assume that A's column number is equal to B's row

原创 [LeetCode308]Range Sum Query 2D - Mutable

Given a 2D matrix matrix, find the sum of the elements inside the rectangle defined by its upper left corner (row1, col

原创 [LeetCode296]Best Meeting Point

A group of two or more people wants to meet and minimize the total travel distance. You are given a 2D grid of values 0