代码改变世界

318_Maximum Product of Word Lengths

2016-01-12 16:12 by FTD_W, 488 阅读, 0 推荐, 收藏, 编辑
摘要:Given a string arraywords, find the maximum value oflength(word[i]) * length(word[j])where the two words do not share common letters. You may assume t... 阅读全文

235_Lowest Common Ancestor of a Binary Search Tree

2016-01-05 15:28 by FTD_W, 166 阅读, 0 推荐, 收藏, 编辑
摘要:Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST.According to thedefinition of LCA on Wikipedia: ... 阅读全文

319_Bulb Switcher

2016-01-04 13:24 by FTD_W, 388 阅读, 0 推荐, 收藏, 编辑
摘要:There arenbulbs that are initially off. You first turn on all the bulbs. Then, you turn off every second bulb. On the third round, you toggle every th... 阅读全文

268_Missing Number

2016-01-03 10:29 by FTD_W, 270 阅读, 0 推荐, 收藏, 编辑
摘要:Given an array containingndistinct numbers taken from0, 1, 2, ..., n, find the one that is missing from the array.For example,Givennums=[0, 1, 3]retur... 阅读全文

94_Binary Tree Inorder Traversal

2015-12-31 10:43 by FTD_W, 134 阅读, 0 推荐, 收藏, 编辑
摘要:Given a binary tree, return theinordertraversal of its nodes' values.For example:Given binary tree{1,#,2,3}, 1 \ 2 / 3return[1,3,2].中序遍历... 阅读全文

144_Binary Tree Preorder Traversal

2015-12-31 10:40 by FTD_W, 136 阅读, 0 推荐, 收藏, 编辑
摘要:前序遍历,递归,先遍历根节点,再遍历左节点/** * Definition for a binary tree node. * public class TreeNode { * public int val; * public TreeNode left; * public... 阅读全文

169_Majority Element

2015-12-29 16:56 by FTD_W, 166 阅读, 0 推荐, 收藏, 编辑
摘要:Given an array of sizen, find the majority element. The majority element is the element that appears more than⌊ n/2 ⌋times.You may assume that the arr... 阅读全文

171_Excel Sheet Column Number

2015-12-25 21:53 by FTD_W, 154 阅读, 0 推荐, 收藏, 编辑
摘要:Given a column title as appear in an Excel sheet, return its corresponding column number.For example: A -> 1 B -> 2 C -> 3 ... Z -> 26 ... 阅读全文

217_Contains Duplicate

2015-12-25 17:20 by FTD_W, 131 阅读, 0 推荐, 收藏, 编辑
摘要:Given an array of integers, find if the array contains any duplicates. Your function should return true if any value appears at least twice in the arr... 阅读全文

242_Valid Anagram

2015-12-25 16:40 by FTD_W, 143 阅读, 0 推荐, 收藏, 编辑
摘要:Given two stringssandt, write a function to determine iftis an anagram ofs.For example,s= "anagram",t= "nagaram", return true.s= "rat",t= "car", retur... 阅读全文