記錄: 2017/6

0

Binary Tree Right Side View

Binary Tree Right Side ViewGiven a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see ordered from top to bottom. For example:Given the followi

0

Repeated DNA Sequences

Repeated DNA SequencesAll DNA is composed of a series of nucleotides abbreviated as A, C, G, and T, for example: “ACGAATTCCG”. When studying DNA, it is sometimes useful to identify repeated sequences

0

Largest Number

Largest NumberGiven a list of non negative integers, arrange them such that they form the largest number. For example, given [3, 30, 34, 5, 9], the largest formed number is 9534330. Note: The result

0

Two Sum II - Input array is sorted

Two Sum II - Input array is sortedGiven an array of integers that is already sorted in ascending order, find two numbers such that they add up to a specific target number. The function twoSum should

0

Find Peak Element

Find Peak ElementA peak element is an element that is greater than its neighbors. Given an input array where num[i] ≠ num[i+1], find a peak element and return its index. The array may contain multipl

0

Find Minimum in Rotated Sorted Array

Find Minimum in Rotated Sorted ArraySuppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand. (i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2). Find the minimum e

0

Maximum Product Subarray

Maximum Product SubarrayFind the contiguous subarray within an array (containing at least one number) which has the largest product. For example:12Given the array [2,3,-2,4],the contiguous subarray [

0

Evaluate Reverse Polish Notation

Evaluate Reverse Polish NotationEvaluate the value of an arithmetic expression in Reverse Polish Notation. Valid operators are +, -, *, /. Each operand may be an integer or another expression. For ex

0

Sort List

Sort ListSort a linked list in O(n log n) time using constant space complexity. 提示 解題應用 LinkedList Pointer Sort MergeSort Default:12345678910/** * Definition for singly-linked list. * typ

0

Insertion Sort List

Insertion Sort ListSort a linked list using insertion sort. 提示 解題應用 LinkedList Pointer Sort Insertion Sort Default:12345678910/** * Definition for singly-linked list. * type ListNode stru

0

Binary Tree Preorder Traversal

Binary Tree Preorder TraversalGiven a binary tree, return the preorder traversal of its nodes’ values. For example:Given binary tree {1,#,2,3}, 123451 \ 2 /3 return [1,2,3]. Note: Recursive solution

0

Reorder List

Reorder ListGiven a singly linked list L: L0→L1→…→Ln-1→Ln,reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→… You must do this in-place without altering the nodes’ values. For example:1Given {1,2,3,4},

0

Word Break

Word BreakGiven a non-empty string s and a dictionary wordDict containing a list of non-empty words, determine if s can be segmented into a space-separated sequence of one or more dictionary words. Y

0

Single Number II

Single Number IIGiven an array of integers, every element appears three times except for one, which appears exactly once. Find that single one. Note: Your algorithm should have a linear runtime compl

0

Gas Station

Gas StationThere are N gas stations along a circular route, where the amount of gas at station i is gas[i]. You have a car with an unlimited gas tank and it costs cost[i] of gas to travel from statio

0

Palindrome Partitioning

Palindrome PartitioningGiven a string s, partition s such that every substring of the partition is a palindrome. Return all possible palindrome partitioning of s. For example:Given s = “aab”,Return 1

0

Sum Root to Leaf Numbers

Sum Root to Leaf NumbersGiven a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a number. An example is the root-to-leaf path 1->2->3 which represents the nu

0

Best Time to Buy and Sell Stock II

Best Time to Buy and Sell Stock IISay you have an array for which the ith element is the price of a given stock on day i. Design an algorithm to find the maximum profit. You may complete as many tran

0

Triangle

TriangleGiven a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below. For example:Given the following triangle 123456[ [2], [3,4]

0

Flatten Binary Tree to Linked List

Flatten Binary Tree to Linked ListGiven a binary tree, flatten it to a linked list in-place. For example:Given 12345 1 / \ 2 5 / \ \3 4 6 The flattened tree should look like: 1234567891

0

Path Sum II

Path Sum IIGiven a binary tree and a sum, find all root-to-leaf paths where each path’s sum equals the given sum. For example:Given the below binary tree and sum = 22, 1234567 5 / \ 4 8

0

Convert Sorted List to Binary Search Tree

Convert Sorted List to Binary Search TreeGiven a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST. 提示 解題應用 DepthFirstSearch InorderTravel