- 博客(129)
- 收藏
- 关注
原创 找工作小总结
找了一学期工作,零零碎碎刷了两遍leetcode,网上各种C++常见问题,JAVA常见问题,OS常见问题之类的每次面前都看了看,准备了一堆behavioral question career fair投简历的公司:第一批全是一月底在TAMU的CAREER FAIR上投的,虽然我不是TAMU的。。。。。投了之后有后续的有NI, DELL, DENIM GROUP, MATHWORKS 面试的公司
2015-04-30 09:38:31
1237
原创 LeetCode - Bitwise AND of Numbers Range
https://leetcode.com/problems/bitwise-and-of-numbers-range/ Given a range [m, n] where 0 For example, given the range [5, 7], you should return 4. 一开始的时候,我是打算从m到n挨个AND,结果超时了,后来发现既然是AND,那么只需要
2015-04-19 23:07:25
602
原创 LeetCode - Merge k Sorted Lists
https://leetcode.com/problems/merge-k-sorted-lists/ Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity. 优快云坑爹博客,之前明明写过这篇,居然找不到了! 之前用JAVA写的代码,现在是用
2015-04-19 00:07:33
385
原创 LeetCode - Valid Parenthesis
https://leetcode.com/problems/valid-parentheses/ Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. The brackets must cl
2015-04-18 22:30:35
431
原创 LeetCode - Maxmimum Gap
https://leetcode.com/problems/maximum-gap/ Given an unsorted array, find the maximum difference between the successive elements in its sorted form. Try to solve it in linear time/space. Ret
2015-04-16 08:11:51
445
原创 LeetCode - LRU Cache
https://leetcode.com/problems/lru-cache/ Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: get and set. get(key) - Get the
2015-04-16 06:45:20
329
原创 LeetCode - Populating Next Right Pointers in Each Node I && II
Populating Next Right Pointers in Each Node I https://leetcode.com/problems/populating-next-right-pointers-in-each-node/ Given a binary tree struct TreeLinkNode { TreeLinkNode *left
2015-04-16 01:11:53
317
原创 LeetCode - Binary Tree Postorder Traversal
https://leetcode.com/problems/binary-tree-postorder-traversal/ 这道题不用递归的话思路还是挺复杂的,网上有用一个栈的,有用两个栈的,我这里写的是用一个栈的,就是一直有一个pre和current的指针,来记录上一个被加入到结果list或者被进入栈的节点。 当pre是current的父节点时,说明pre还没有处理过(postorder)
2015-04-16 00:47:02
379
原创 LeetCode - Binary Tree Maximum Path Sum
https://leetcode.com/problems/binary-tree-maximum-path-sum/ 这道题可以用递归做,首先,应该有一个全局变量来保存当前遇到的最大path值。 对于每个节点而言,经过它的最大path值,应该是左边的最大path加右边的最大path加自己,如果左边或者右边的最大path是负数,那么就不加这一部分。 另外,对于这个节点的父节点而言,经过父节点
2015-04-16 00:23:29
386
原创 LeetCode - Palindrome Partitioning I && II
Palindrome Partitioning I https://leetcode.com/problems/palindrome-partitioning/ Given a string s, partition s such that every substring of the partition is a palindrome. Return all possibl
2015-04-15 23:33:36
379
原创 Google电面面经总结
1. 上来问了tree里node求和的问题 很简单 然后follow up 给一个range 求range里的node值的和,不是path sum 是所有节点的求和 然后给个range 值在range之内就加进去 然后分析不同的树怎么优化 2. encoding,把 abcccdaa 这种字符串变为 ab3xcd2xa 这种 3. 给一个String的array,问
2015-04-13 01:48:27
3179
原创 LeetCode - Regular Expression Matching
https://leetcode.com/problems/regular-expression-matching/ Implement regular expression matching with support for '.' and '*'. '.' Matches any single character. '*' Matches zero or more of the p
2015-04-12 09:07:53
363
原创 LeetCode - Candy
https://leetcode.com/problems/candy/ There are N children standing in a line. Each child is assigned a rating value. You are giving candies to these children subjected to the following require
2015-04-12 03:17:05
430
原创 LeetCode - Recover Binary Search Tree
https://leetcode.com/problems/recover-binary-search-tree/ Two elements of a binary search tree (BST) are swapped by mistake. Recover the tree without changing its structure. Note: A solution
2015-04-11 02:16:53
472
原创 LeetCode - N-Queens I && II
N-Queens I https://leetcode.com/problems/n-queens/ Given an integer n, return all distinct solutions to the n-queens puzzle. Each solution contains a distinct board configuration of the n-q
2015-04-11 01:25:00
357
原创 LeetCode - Permutations II
https://leetcode.com/problems/permutations-ii/ Given a collection of numbers that might contain duplicates, return all possible unique permutations. For example, [1,1,2] have the following un
2015-04-11 00:43:36
345
原创 LeetCode - Permutations
https://leetcode.com/problems/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,3],
2015-04-11 00:40:14
348
原创 LeetCode - Word Break II
https://leetcode.com/problems/word-break-ii/ Given a string s and a dictionary of words dict, add spaces in s to construct a sentence where each word is a valid dictionary word. Return all suc
2015-04-10 23:53:42
303
原创 LeetCode - Word Break
https://leetcode.com/problems/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
2015-04-10 04:57:01
331
原创 LeetCode - Dungeon Game
https://leetcode.com/problems/dungeon-game/ The demons had captured the princess (P) and imprisoned her in the bottom-right corner of a dungeon. The dungeon consists of M x N rooms laid out in a
2015-04-10 04:23:55
400
原创 LeetCode - Distinct Subsequences
https://leetcode.com/problems/distinct-subsequences/ 这道题一开始我还想用 two pointers , backtracking来做,后来想这个是算个数,backtracking太复杂了,而且也没想到很明确的做法。 后来看tag发现是DP题,分析一下: a b c d a e b c a
2015-04-10 00:43:08
293
原创 LeetCode - Decode Ways
https://leetcode.com/problems/decode-ways/ A message containing letters from A-Z is being encoded to numbers using the following mapping: 'A' -> 1 'B' -> 2 ... 'Z' -> 26 Given an encoded m
2015-04-10 00:17:21
227
原创 LeetCode - Edit Distance
https://leetcode.com/problems/edit-distance/ Given two words word1 and word2, find the minimum number of steps required to convert word1 to word2. (each operation is counted as 1 step.) You ha
2015-04-09 23:32:22
246
原创 LeetCode - Generate Parentheses
https://leetcode.com/problems/generate-parentheses/ Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses. For example, given n = 3, a solution
2015-04-09 23:05:17
273
原创 LeetCode - Interleaving String
https://leetcode.com/problems/interleaving-string/ Given s1, s2, s3, find whether s3 is formed by the interleaving of s1 and s2. For example, Given: s1 = "aabcc", s2 = "dbbca", When s3 =
2015-04-09 22:47:30
219
原创 LeetCode - Maximum Depth of Binary Tree
https://leetcode.com/problems/maximum-depth-of-binary-tree/ Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the longest path from the root node down
2015-04-08 01:11:40
384
原创 LeetCode - Validate Binary Search Tree
https://leetcode.com/problems/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
2015-04-08 00:32:21
337
原创 LeetCode - Longest Palindromic Substring
https://leetcode.com/problems/longest-palindromic-substring/ Given a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 1000, and there exists
2015-04-07 01:47:18
251
原创 LeetCode - Longest Valid Parentheses
https://leetcode.com/problems/longest-valid-parentheses/ Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring.
2015-04-07 01:07:21
389
原创 LeetCode - One Edit Distance
https://leetcode.com/problems/one-edit-distance/ Given two strings S and T, determine if they are both one edit distance apart. One Edit Distance即是: 1. 插入一个字符 2. 更改一个字符, 如ab->ac 所以分情况是: 1. 如果两
2015-04-07 00:42:53
261
原创 LeetCode - Read N Characters Given Read4 I && II
https://leetcode.com/problems/read-n-characters-given-read4/ The API: int read4(char *buf) reads 4 characters at a time from a file. The return value is the actual number of characters read. F
2015-04-06 23:45:34
390
原创 LeetCode - Restore IP Addresses
https://leetcode.com/problems/restore-ip-addresses/ Given a string containing only digits, restore it by returning all possible valid IP address combinations. For example: Given "2552551113
2015-04-04 07:10:19
249
原创 LeetCode - Reverse Words in a String I && II
https://leetcode.com/problems/reverse-words-in-a-string/ 这道题O(n)的方法很简单,就是遍历字符串,找到一个词就放到list里面,遍历完后把list里面的单词从后往前连起来就行。 而且本来我想用JAVA的s.split(" ")函数的,结果leetcode的用例全部都是不规律的,两个单词间N多空格,或者字符串前后都是空格之类的,所以用s
2015-04-04 06:24:36
386
原创 LeetCode - Scramble String
https://leetcode.com/problems/scramble-string/ Given a string s1, we may represent it as a binary tree by partitioning it to two non-empty substrings recursively. Below is one possible represe
2015-04-04 05:17:15
353
原创 LeetCode - Simplify Path
https://leetcode.com/problems/simplify-path/ Given an absolute path for a file (Unix-style), simplify it. For example, path = "/home/", => "/home" path = "/a/./b/../../c/", => "/c" clic
2015-04-04 04:45:18
277
原创 LeetCode - Text Justification
https://leetcode.com/problems/text-justification/ Given an array of words and a length L, format the text such that each line has exactly L characters and is fully (left and right) justified.
2015-04-04 04:15:28
418
原创 LeetCode - Wildcard Matching
https://leetcode.com/problems/wildcard-matching/ Implement wildcard pattern matching with support for '?' and '*'. '?' Matches any single character. '*' Matches any sequence of characters (inclu
2015-04-03 23:55:38
573
原创 LeetCode - ZigZag Conversion
https://leetcode.com/problems/zigzag-conversion/ The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed
2015-04-03 22:45:57
217
原创 LeetCode - Merge Two Sorted Lists
https://leetcode.com/problems/merge-two-sorted-lists/ 这用到的就是merge sort里面的merge函数,只不过这里是在merge list。 public class Solution { public ListNode mergeTwoLists(ListNode l1, ListNode l2) { Li
2015-04-03 05:40:46
208
原创 LeetCode - Reverse Linked List II
https://leetcode.com/problems/reverse-linked-list-ii/ 这道题跟其他reverse node 的题差不多,只要找到需要reverse的node之前的那个node,再把这个node后面的n-m+1个node掉转就行。 如果head node也需要被reverse的话,它之前没有node了,所以需要在前面加一个dummy node public
2015-04-03 05:12:11
290
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅