2015年3月7日

Spiral Matrix II

摘要: Spiral Matrix II问题:Given an integern, generate a square matrix filled with elements from 1 ton2in spiral order.思路: 矩阵的旋转常用模板我的代码1:public class Soluti... 阅读全文

posted @ 2015-03-07 20:30 zhouzhou0615 阅读(162) 评论(0) 推荐(0) 编辑

Symmetric Tree

摘要: Symmetric Tree问题:Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).思路: dfs我的代码:public class Solution { ... 阅读全文

posted @ 2015-03-07 19:39 zhouzhou0615 阅读(110) 评论(0) 推荐(0) 编辑

Rotate Image

摘要: Rotate Image问题:You are given annxn2D matrix representing an image.Rotate the image by 90 degrees (clockwise).Follow up:Could you do this in-place?思路: ... 阅读全文

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

Minimum Path Sum

摘要: Minimum Path Sum问题:Given amxngrid filled with non-negative numbers, find a path from top left to bottom right whichminimizesthe sum of all numbers alo... 阅读全文

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

Populating Next Right Pointers in Each Node II

摘要: Populating Next Right Pointers in Each Node II问题:Populate each next pointer to point to its next right node. If there is no next right node, the next ... 阅读全文

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

Permutations

摘要: Permutations问题:Given a collection of numbers, return all possible permutations.For example,[1,2,3]have the following permutations:[1,2,3],[1,3,2],[2,1... 阅读全文

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

Balanced Binary Tree

摘要: Balanced Binary Tree问题:Given a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined as a binary ... 阅读全文

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

Best Time to Buy and Sell Stock

摘要: Best Time to Buy and Sell Stock问题:Say you have an array for which theithelement is the price of a given stock on dayi.If you were only permitted to co... 阅读全文

posted @ 2015-03-07 14:53 zhouzhou0615 阅读(114) 评论(0) 推荐(0) 编辑

Swap Nodes in Pairs

摘要: Swap Nodes in Pairs问题:Given a linked list, swap every two adjacent nodes and return its head.For example,Given1->2->3->4, you should return the list a... 阅读全文

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

Remove Element

摘要: Remove Element问题:Given an array and a value, remove all instances of that value in place and return the new length.The order of elements can be change... 阅读全文

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

导航