- 博客(17)
- 资源 (1)
- 收藏
- 关注
原创 Leetcode NO.226 Invert Binary Tree
本题题目要求如下:Invert a binary tree. 4 / \ 2 7 / \ / \1 3 6 9to 4 / \ 7 2 / \ / \9 6 3 1。。。。前一段时间,这道题挺火的。。说一个面谷歌的大神没做出来。。。反正我是不信。。。这几乎是leetcode最简单
2015-07-29 13:17:52 321
原创 Leetcode NO.19 Remove Nth Node From End of List
本题题目要求如下:Given a linked list, remove the nth node from the end of list and return its head.For example, Given linked list: 1->2->3->4->5, and n = 2. After removing the second node fr
2015-07-29 12:53:31 340
原创 Leetcode NO.139 Word Break
本题题目要求如下:Given a string s and a dictionary of words dict, determine if s can be segmented into a space-separated sequence of one or more dictionary words.For example, givens = "leetcode",
2015-07-29 06:42:02 570
原创 Leetcode NO.13 Roman to Integer
本题题目要求如下:Given a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1 to 3999.本题题目还是很简单的,就是设一个hashmap,让字母和对应数字分别为key和value需要注意的是如果后面字母大于前面字母对应的数字,应该是
2015-07-27 07:22:31 514
原创 Two Sigma面试专题
前段时间过了Two Sigma的第一轮HR面后,就一直没有管,最近准备把Two Sigma的OA做了,不过还是提前准备下,从网上找了几道面经,准备写一写,尽量能过OA面吧,如果过了,下一轮就是技术电话面试。。。以前还从未有过这样的面试,所以想这次试一试。。Two Sigma NO.1 Friend CircleProblem StatementThere
2015-07-25 04:56:51 10893
原创 Leetcode NO.20 Valid Parentheses
本题题目要求如下:Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.The brackets must close in the correct order, "()" and "()[]{
2015-07-24 09:40:06 505
原创 Leetcode NO.170 Two Sum III - Data structure design
本题题目要求如下:Design and implement a TwoSum class. It should support the following operations: add and find.add - Add the number to an internal data structure.find - Find if there exists any pa
2015-07-24 05:35:06 384
原创 Leetcode NO.111 Minimum Depth of Binary Tree
本题题目要求如下: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.这道题是一道很简单的题目,基本思想就是DF
2015-07-23 07:09:58 339
原创 Leetcode NO.155 Min Stack
本题题目要求如下:Design a stack that supports push, pop, top, and retrieving the minimum element in constant time.push(x) -- Push element x onto stack.pop() -- Removes the element on top of the stac
2015-07-23 05:14:36 330
原创 Leetcode NO.236 Lowest Common Ancestor of a Binary Tree
本题题目要求如下:Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree.According to the definition of LCA on Wikipedia: “The lowest common ancestor is defined b
2015-07-21 05:13:30 526
原创 Pocket Gems面试专题
自从3月被Epic据了之后,在1个月前才开始正式投简历,开始正式找工作,这次是第一个技术电面,虽然Pocket Gems在面试中风评不好,但还是希望能够把握住机会,争取最少过一轮电面!Pocket Gems NO.1 Strstr()这题在Leetcode上有原题,用brute force解出,虽然也可以用KMP解,但感觉作为电面第一轮,KMP有点太过于难。代码如下:NO.28
2015-07-20 10:52:09 3571 2
原创 Leetcode NO.28 Implement strStr()
本题题目要求如下:Implement strStr().Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.这题没啥好说的,用brute force即可:class Solution {public:
2015-07-20 06:02:48 580
原创 Leetcode NO.237 Delete Node in a Linked List
本题题目要求如下:Write a function to delete a node (except the tail) in a singly linked list, given only access to that node.Supposed the linked list is 1 -> 2 -> 3 -> 4 and you are given the third
2015-07-19 03:12:48 315
原创 Leetcode NO.143 Reorder List
本题题目要求如下:Given a singly linked list L: L0→L1→…→Ln-1→Ln,reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→…You must do this in-place without altering the nodes' values.For example,Given {1,2,3,4},
2015-07-14 05:18:41 399
原创 Leetcode NO.235 Lowest Common Ancestor of a Binary Search Tree
本题题目要求如下:Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST.According to the definition of LCA on Wikipedia: “The lowest common ancestor is
2015-07-13 06:48:20 729
原创 Leetcode NO.234 Palindrome Linked List
本题题目要求如下:Given a singly linked list, determine if it is a palindrome.Follow up:Could you do it in O(n) time and O(1) space?本题的思路其实并不难,但是我一直觉得直接手写一个iterative版本的reverse linked list还是有一点难度的
2015-07-11 04:51:44 476
原创 Leetcode NO.231 Power of Two
本题题目要求如下:Given an integer, write a function to determine if it is a power of two.很简单的要求,不过一开始我居然没有想到解决问题的办法,用一种很傻的方法做的,后来感觉不对,看了提示,用位运算解决,才恍然大悟,用简单方法解决了问题。。power of 2的数看十进制,没有什么特别的地方,但是转换成二进制之
2015-07-10 07:12:59 630
Algorithm in C++, Part 1 - Part 4
2014-02-23
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人