原创 LeetCode OJ 207. Course Schedule

LeetCode OJ 207. Course Schedule 典型的拓撲排序算法。謹以此題紀念期末機考時沒AC這麼簡單的拓撲排序。upset……ing Description There are a total of n c

原创 LeetCode OJ 515. Find Largest Value in Each Tree Row

LeetCode OJ 515. Find Largest Value in Each Tree Row Description You need to find the largest value in each row of

原创 LeetCode OJ 105. Construct Binary Tree from Preorder and Inorder Traversal

LeetCode OJ 105. Construct Binary Tree from Preorder and Inorder Traversal Description Given preorder and inorder

原创 LeetCode OJ 106. Construct Binary Tree from Inorder and Postorder Traversal

LeetCode OJ 106. Construct Binary Tree from Inorder and Postorder Traversal Description Given inorder and postorde

原创 LeetCode OJ 513. Find Bottom Left Tree Value

LeetCode OJ 513. Find Bottom Left Tree Value Description Given a binary tree, find the leftmost value in the last

原创 LeetCode OJ 50. Pow(x, n)

LeetCode OJ 50. Pow(x, n) Description Implement pow(x, n). 解題思路 最簡單的思路是循環n次,做n次乘法,這樣的複雜度是O(n)。但是有一種更好的做法:根據對稱性,我們可

原创 LeetCode OJ 451. Sort Characters By Frequency

LeetCode OJ 451. Sort Characters By Frequency Description Given a string, sort it in decreasing order based on the

原创 LeetCode OJ 405. Convert a Number to Hexadecimal

LeetCode OJ 405. Convert a Number to Hexadecimal Description Given an integer, write an algorithm to convert it to

原创 LeetCode OJ 503. Next Greater Element II

LeetCode OJ 503. Next Greater Element II Description Given a circular array (the next element of the last element is t

原创 LeetCode OJ 406. Queue Reconstruction by Height

LeetCode OJ 406. Queue Reconstruction by Height Description Suppose you have a random list of people standing in a que

原创 LeetCode OJ 442. Find All Duplicates in an Array

LeetCode OJ 442. Find All Duplicates in an Array Description Given an array of integers, 1 ≤ a[i] ≤ n (n = size of arr

原创 LeetCode OJ 240. Search a 2D Matrix II

LeetCode OJ 240. Search a 2D Matrix II Description Write an efficient algorithm that searches for a value in an m x n

原创 LeetCode OJ 399. Evaluate Division

LeetCode OJ 399. Evaluate Division Description Equations are given in the format A / B = k, where A and B are variable

原创 LeetCode OJ 12. Integer to Roman

LeetCode OJ 513. Find Bottom Left Tree Value Description Given an integer, convert it to a roman numeral. Input is gua

原创 LeetCode OJ 62. Unique Paths

LeetCode OJ 62. Unique Paths Description A robot is located at the top-left corner of a m x n grid (marked ‘Start’ in