記錄: 2016

0

Minimum Depth of Binary Tree

Minimum Depth of Binary TreeGiven a binary tree, find its minimum depth. The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node. 提示 解題應用

0

Balanced Binary Tree

Balanced Binary TreeGiven a binary tree, determine if it is height-balanced. For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the two subtrees of ever

0

Binary Tree Level Order Traversal II

Binary Tree Level Order Traversal IIGiven a binary tree, return the bottom-up level order traversal of its nodes’ values. (ie, from left to right, level by level from leaf to root). For example:Given

0

Maximum Depth of Binary Tree

Maximum Depth of Binary TreeGiven a binary tree, find its maximum depth. The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node. 提示 解題應用

0

Binary Tree Level Order Traversal

Binary Tree Level Order TraversalGiven a binary tree, return the level order traversal of its nodes’ values. (ie, from left to right, level by level). For example:Given binary tree [3,9,20,null,null,

0

Symmetric Tree

Symmetric TreeGiven a binary tree, check whether it is a mirror of itself (ie, symmetric around its center). For example, this binary tree [1,2,2,3,4,4,3] is symmetric: 12345 1 / \ 2 2 / \ /

0

Same Tree

Same TreeGiven two binary trees, write a function to check if they are equal or not. Two binary trees are considered equal if they are structurally identical and the nodes have the same value. 提示

0

Merge Sorted Array

Merge Sorted ArrayGGiven two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array. Note: You may assume that nums1 has enough space (size that is greater or equal to m +

0

Remove Duplicates from Sorted List

Remove Duplicates from Sorted ListGiven a sorted linked list, delete all duplicates such that each element appear only once. For example:12Given 1->1->2, return 1->2.Given 1->1->2->

0

Climbing Stairs

Climbing StairsYou are climbing a stair case. It takes n steps to reach to the top. Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top? 提示 解題應用 Dyn

0

Add Binary

Add BinaryGiven two binary strings, return their sum (also a binary string). For Example:123a = "11"b = "1"Return "100". 提示 解題應用 String 觀查規律 Math 觀查規律 Defaul

0

Plus One

Plus OneGiven a non-negative number represented as an array of digits, plus one to the number. The digits are stored such that the most significant digit is at the head of the list. 提示 解題應用 Ar

0

Length of Last Word

Length of Last WordGiven a string s consists of upper/lower-case alphabets and empty space characters ‘ ‘, return the length of last word in the string. If the last word does not exist, return 0. Not

0

Count and Say

Count and SayThe count-and-say sequence is the sequence of integers beginning as follows:1, 11, 21, 1211, 111221, … 1 is read off as “one 1” or 11. 11 is read off as “two 1s” or 21. 21 is read off a

0

Valid Sudoku

Valid SudokuThe Sudoku board could be partially filled, where empty cells are filled with the character ‘.’. Note: A valid Sudoku board (partially filled) is not necessarily solvable. Only the fille

0

Remove Element

Remove ElementGiven an array and a value, remove all instances of that value in place and return the new length. Do not allocate extra space for another array, you must do this in place with constant

0

Swap Nodes in Pairs

Swap Nodes in PairsGiven a linked list, swap every two adjacent nodes and return its head. For example: 1Given 1->2->3->4, you should return the list as 2->1->4->3. Your algorithm s

0

Remove Duplicates from Sorted Array

Remove Duplicates from Sorted ArrayGiven a sorted array, remove the duplicates in place such that each element appear only once and return the new length. Do not allocate extra space for another arra

0

Merge Two Sorted Lists

Merge Two Sorted ListsMerge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists. 提示 解題應用 LinkedList Pointer

0

Valid Parentheses

Valid ParenthesesGiven a string containing just the characters ‘(‘, ‘)’, ‘{‘, ‘}’, ‘[‘ and ‘]’, determine if the input string is valid. The brackets must close in the correct order, “()” and “()[]{}”

0

Remove Nth Node From End of List

Remove Nth Node From End of ListGiven a linked list, remove the nth node from the end of list and return its head. Example: 123Given linked list: 1->2->3->4->5, and n = 2.After removing t

0

Longest Common Prefix

Longest Common PrefixWrite a function to find the longest common prefix string amongst an array of strings. 提示 解題應用 String Prefix String Default:123func longestCommonPrefix(strs []string) s