我也做面试题
文章平均质量分 74
迷失湾区
在湾区迷失自己
展开
-
Permutations - 10 minutes.
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,3], [2,3,1], [3,1,2], and [3,2,1].原创 2014-04-29 13:46:28 · 387 阅读 · 0 评论 -
Haha. 5 min.
Valid Parentheses Total Accepted: 10193 Total Submissions: 36812My SubmissionsGiven a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input stri原创 2014-05-02 15:19:04 · 361 阅读 · 0 评论 -
15分钟 - Gas Station
Gas Station原创 2014-05-02 11:23:59 · 445 阅读 · 0 评论 -
1分钟 - Linked List Cycle II
Given a linked list, return the node where the cycle begins. If there is no cycle, return null.Follow up:Can you solve it without using extra space?/** * Definition for singly-linked list.原创 2014-05-03 04:27:00 · 408 阅读 · 0 评论 -
8 mins - Populating Next Right Pointers in Each Node II
Follow up for problem "Populating Next Right Pointers in Each Node".What if the given tree could be any binary tree? Would your previous solution still work?Note:You may only use constant原创 2014-05-03 09:29:44 · 297 阅读 · 0 评论 -
竟然用了40分钟。。Binary Tree Maximum Path Sum
/** * Definition for binary tree * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; } * } */public class Solution {原创 2014-04-01 14:56:23 · 423 阅读 · 0 评论 -
10 mins - Validate Binary Search Tree
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 nodes with keys less than the node's key.Th原创 2014-04-02 11:51:38 · 362 阅读 · 0 评论 -
失败:Flatten Binary Tree to Linked List
问题:Given a binary tree, flatten it to a linked list in-place.For example,Given 1 / \ 2 5 / \ \ 3 4 6The flattened tree should原创 2014-04-02 08:39:15 · 366 阅读 · 0 评论 -
想到这一点,只要10分钟不到 - First Missing Positive
问题有点迷惑性。后来想到他们没有要求不能修改A,也就简单多了。Given an unsorted integer array, find the first missing positive integer.For example,Given [1,2,0] return 3,and [3,4,-1,1] return 2.Your algorithm原创 2014-04-03 01:15:44 · 448 阅读 · 0 评论 -
30+ mins -- ZigZag Conversion
用了大概20分钟写解法,直接写的最优解法。(貌似也没有啥原创 2014-04-26 11:48:33 · 379 阅读 · 0 评论 -
6分钟 Longest Common Prefix
Longest Common PrefixcmnIdx的处理有些问题,3分钟写完,3分钟调试,一共6分钟。原创 2014-05-01 00:42:43 · 445 阅读 · 0 评论 -
30+ minutes - Sqrt(x)
Sqrt(x)原创 2014-05-01 12:01:54 · 780 阅读 · 0 评论 -
Permutation Sequence - 20 mins
10分钟就写完了,另外10分钟用来调试。一个k的处理就搞去起码8分钟。。Permutation Sequence T原创 2014-04-29 23:43:18 · 415 阅读 · 0 评论 -
做了30分钟。。Merge Interval
Given a collection of intervals, merge all overlapping intervals.For example,Given [1,3],[2,6],[8,10],[15,18],return [1,6],[8,10],[15,18].原创 2014-04-30 00:50:10 · 537 阅读 · 0 评论 -
面试题:Add Two Numbers
这个题目做的很顺利,竟然一次就通过了。10分钟都没用到。You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two原创 2014-03-30 23:37:34 · 431 阅读 · 0 评论 -
面试题:Minimum Depth of Binary Tree
这个也好顺,8分钟做完,没有报错。Given 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./**原创 2014-03-30 23:50:13 · 404 阅读 · 0 评论 -
Rotate Image (bi-matrix)
You are given an n x n 2D matrix representing an image.Rotate the image by 90 degrees (clockwise).Follow up:Could you do this in-place?Answer 1:Not difficult. With 15 mins I fini原创 2014-03-29 08:07:51 · 355 阅读 · 0 评论 -
30 分钟 - Construct Binary Tree from Inorder and Postorder Traversal
递归的出入口没有做好折腾了半天。原创 2014-05-03 01:07:30 · 430 阅读 · 0 评论 -
傻的一塌糊涂 - 30分钟的 2 SUM = Two Sum
Two Sum原创 2014-05-01 01:32:04 · 498 阅读 · 0 评论 -
15 minutes - Binary Tree Zigzag level order traversal
Binary Tree Zigzag Level Order Traversal Total Accepted: 8216 Total Submissions: 31341My SubmissionsGiven a binary tree, return the zigzag level order traversal of its nodes' values. (ie原创 2014-05-02 15:09:22 · 372 阅读 · 0 评论 -
不知道写了多久。TestCase自己有问题:Combination Sum
Given a set of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T.The same repeated number may be chosen from C unlimited number原创 2014-05-02 17:13:55 · 503 阅读 · 0 评论 -
一晚上 -- Populating Next Right Pointers in Each Node II
先使用分层cache做了一遍报内存超标。用这个办法又做了一遍。不过有一个问题始终搞不定原来关键在于后面要先做右边在做左边。因为你不准备好右边,左边没有东西指啊。。https://leetcode.com/problems/populating-next-right-pointers-in-each-node-ii//** * Definition for binary原创 2015-06-14 14:50:22 · 438 阅读 · 0 评论