摘要: You are given annxn2D matrix representing an image.Rotate the image by 90 degrees (clockwise).Follow up:Could you do this in-place?思路:将这个矩阵沿左对角线(从左上角到... 阅读全文
posted @ 2016-01-27 13:07 fenshen371 阅读(160) 评论(0) 推荐(0) 编辑
摘要: Given a set of distinct integers,nums, return all possible subsets.Note:Elements in a subset must be in non-descending order.The solution set must not... 阅读全文
posted @ 2016-01-27 12:48 fenshen371 阅读(149) 评论(0) 推荐(0) 编辑
摘要: Given a string containing just the characters'(',')','{','}','['and']', determine if the input string is valid.The brackets must close in the correct ... 阅读全文
posted @ 2016-01-27 12:18 fenshen371 阅读(164) 评论(0) 推荐(0) 编辑
摘要: Given an array of strings, group anagrams together.For example, given:["eat", "tea", "tan", "ate", "nat", "bat"],Return:[ ["ate", "eat","tea"], ["na... 阅读全文
posted @ 2016-01-27 12:08 fenshen371 阅读(153) 评论(0) 推荐(0) 编辑
摘要: Given an arraynumscontainingn+ 1 integers where each integer is between 1 andn(inclusive), prove that at least one duplicate number must exist. Assume... 阅读全文
posted @ 2016-01-27 09:18 fenshen371 阅读(130) 评论(0) 推荐(0) 编辑
摘要: Mergeksorted linked lists and return it as one sorted list. Analyze and describe its complexity.思路:构建一个大小为K的小顶堆。每次从堆顶取走一个元素后,都将这个元素所属的链表中下一个元素加入堆中。若没有... 阅读全文
posted @ 2016-01-27 08:47 fenshen371 阅读(181) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree, determine if it is a valid binary search tree (BST).Assume a BST is defined as follows:The left subtree of a node contains only n... 阅读全文
posted @ 2016-01-27 06:36 fenshen371 阅读(145) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree, return thelevel ordertraversal of its nodes' values. (ie, from left to right, level by level).For example:Given binary tree{3,9,2... 阅读全文
posted @ 2016-01-27 06:00 fenshen371 阅读(160) 评论(0) 推荐(0) 编辑