2015年3月13日

Valid Parentheses

摘要: Valid Parentheses问题:Given a string containing just the characters'(',')','{','}','['and']', determine if the input string is valid.The brackets must c... 阅读全文

posted @ 2015-03-13 21:21 zhouzhou0615 阅读(148) 评论(0) 推荐(0) 编辑

Partition List

摘要: Partition List问题:Given a linked list and a valuex, partition it such that all nodes less thanxcome before nodes greater than or equal tox.You should p... 阅读全文

posted @ 2015-03-13 21:08 zhouzhou0615 阅读(140) 评论(0) 推荐(0) 编辑

Construct Binary Tree from Inorder and Postorder Traversal

摘要: Construct Binary Tree from Inorder and Postorder Traversal问题: Given inorder and postorder traversal of a tree, construct the binary tree.思路: dfs我的代码... 阅读全文

posted @ 2015-03-13 20:10 zhouzhou0615 阅读(95) 评论(0) 推荐(0) 编辑

Triangle

摘要: Triangle问题:Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.思路: 简单的动态规划问题我... 阅读全文

posted @ 2015-03-13 19:52 zhouzhou0615 阅读(112) 评论(0) 推荐(0) 编辑

Binary Search Tree Iterator

摘要: Binary Search Tree Iterator问题:Implement an iterator over a binary search tree (BST). Your iterator will be initialized with the root node of a BST.Cal... 阅读全文

posted @ 2015-03-13 19:37 zhouzhou0615 阅读(133) 评论(0) 推荐(0) 编辑

Convert Sorted List to Binary Search Tree

摘要: Convert Sorted List to Binary Search Tree问题:Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced B... 阅读全文

posted @ 2015-03-13 17:11 zhouzhou0615 阅读(114) 评论(0) 推荐(0) 编辑

Rotate List

摘要: Rotate List问题:Given a list, rotate the list to the right bykplaces, wherekis non-negative.思路: 简单的数学推导问题我的代码:public class Solution { public ListNod... 阅读全文

posted @ 2015-03-13 16:32 zhouzhou0615 阅读(109) 评论(0) 推荐(0) 编辑

3Sum Closest

摘要: 3Sum Closest问题:Given an arraySofnintegers, find three integers inSsuch that the sum is closest to a given number, target. Return the sum of the three ... 阅读全文

posted @ 2015-03-13 16:07 zhouzhou0615 阅读(140) 评论(0) 推荐(0) 编辑

3Sum

摘要: 3Sum问题: Given an arraySofnintegers, are there elementsa,b,cinSsuch thata+b+c= 0? Find all unique triplets in the array which gives the sum of zero.思路... 阅读全文

posted @ 2015-03-13 15:41 zhouzhou0615 阅读(142) 评论(0) 推荐(0) 编辑

Two Sum

摘要: Two Sum问题:Given an array of integers, find two numbers such that they add up to a specific target number.The function twoSum should return indices of ... 阅读全文

posted @ 2015-03-13 14:44 zhouzhou0615 阅读(122) 评论(0) 推荐(0) 编辑

Binary Tree Maximum Path Sum

摘要: Binary Tree Maximum Path Sum问题:Given a binary tree, find the maximum path sum.The path may start and end at any node in the tree.思路: dfs我的代码:public c... 阅读全文

posted @ 2015-03-13 10:51 zhouzhou0615 阅读(115) 评论(0) 推荐(0) 编辑

Path Sum II

摘要: Path Sum II问题:Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum.思路: dfs + 回溯我的代码:public class Sol... 阅读全文

posted @ 2015-03-13 10:07 zhouzhou0615 阅读(116) 评论(0) 推荐(0) 编辑

Merge k Sorted Lists

摘要: Merge k Sorted Lists问题:Mergeksorted linked lists and return it as one sorted list. Analyze and describe its complexity.思路: 归并排序(二分问题)我的代码:public clas... 阅读全文

posted @ 2015-03-13 09:50 zhouzhou0615 阅读(142) 评论(0) 推荐(0) 编辑

导航