- 博客(39)
- 收藏
- 关注
原创 208. Implement Trie (Prefix Tree)
Implement a trie with insert, search, and startsWith methods.Note:You may assume that all inputs are consist oflowercase letters a-z.題義:實作一個trie樹,有插入(insert)、搜索(search)與從前綴搜索(startsWith)方法,可以假
2018-06-29 21:55:36
203
2
原创 找工作心得 part1
本人某大CS碩畢,碩班期間在搜狐焦點實習了3個月,跟板上300萬大大還有30CM大大比簡直是弱到跟渣一樣。然後在大陸與台灣分別都找了工作,首先我先分享在大陸找工作的經驗,下面則是心得與面試題目:Microsoft 北京工程院 小冰開發組 NLP InternM$大家都懂,而工程院就是將研究院研究的東西付諸實現,然後小冰就是一個對話萌妹子機器人,會唱歌做詩啥的,可以在微信加她的公眾號,跟她喇低賽。此...
2018-06-29 21:54:26
609
原创 445. Add Two Numbers II
You are given two non-empty linked lists representing two non-negative integers. The most significant digit comes first and each of their nodes contain a single digit. Add the two numbers and return i
2017-09-13 11:33:35
210
原创 100. Same Tree
Given two binary trees, write a function to check if they are equal or not.Two binary trees are considered equal if they are structurally identical and the nodes have the same value.題意:
2017-09-12 11:10:34
216
原创 523. Continuous Subarray Sum
Given a list of non-negative numbers and a target integer k, write a function to check if the array has a continuous subarray of size at least 2 that sums up to the multiple of k, that is, sums up t
2017-08-28 16:04:43
231
原创 543. Diameter of Binary Tree
Given a binary tree, you need to compute the length of the diameter of the tree. The diameter of a binary tree is the length of the longest path between any two nodes in a tree. This path may or may n
2017-08-23 15:14:57
194
原创 566. Reshape the Matrix
In MATLAB, there is a very useful function called 'reshape', which can reshape a matrix into a new one with different size but keep its original data.You're given a matrix represented by a two-dim
2017-08-22 18:00:47
178
原创 563. Binary Tree Tilt
Given a binary tree, return the tilt of the whole tree.The tilt of a tree node is defined as the absolute difference between the sum of all left subtree node values and the sum of all right subtree
2017-08-21 11:04:57
255
原创 113. Path Sum II
Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum.For example:Given the below binary tree and sum = 22, 5 / \
2017-08-14 15:26:55
250
原创 112. Path Sum
Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum.For example:Given the below binary tree and sum
2017-08-14 14:54:18
184
原创 162. Find Peak Element
A peak element is an element that is greater than its neighbors.Given an input array where num[i] ≠ num[i+1], find a peak element and return its index.The array may contain multiple peaks, in
2017-08-14 14:32:56
218
原创 207. Course Schedule
There are a total of n courses you have to take, labeled from 0 to n - 1.Some courses may have prerequisites, for example to take course 0 you have to first take course 1, which is expressed as
2017-08-14 10:43:58
260
原创 94. Binary Tree Inorder Traversal
Given a binary tree, return the inorder traversal of its nodes' values.For example:Given binary tree [1,null,2,3], 1 \ 2 / 3return [1,3,2].Note: Recursive solution i
2017-08-10 14:44:46
175
原创 144. Binary Tree Preorder Traversal
Given a binary tree, return the preorder traversal of its nodes' values.For example:Given binary tree {1,#,2,3}, 1 \ 2 / 3return [1,2,3].Note: Recursive solution is
2017-08-10 10:50:50
173
原创 關於單例模式的理解
最近面了好多家公司,幾乎都會問到有關單例模式的問題,當然基礎的單例模式大家可能都寫得出來,但面試官深入問下去呢?很可能就矇了,所以在這裡就整理幾個單例模式防止自己忘記。單例模式是做什麼的?根據維基百科的解釋:單例模式,也叫單子模式,是一種常用的軟件設計模式。 在應用這個模式時,單例對象的類必須保證只有一個實例存在。 許多時候整個系統只需要擁有一個的全局對象,這樣有利於我們協調系統整
2017-08-09 16:14:57
222
原创 354. Russian Doll Envelopes
You have a number of envelopes with widths and heights given as a pair of integers (w, h). One envelope can fit into another if and only if both the width and height of one envelope is greater than
2017-08-09 15:34:36
236
原创 174. 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 2D grid. Our valiant knight (K) was initially
2017-08-09 10:23:15
167
原创 329. Longest Increasing Path in a Matrix
Given an integer matrix, find the length of the longest increasing path.From each cell, you can either move to four directions: left, right, up or down. You may NOT move diagonally or move outside
2017-08-08 17:54:46
197
原创 71. Simplify Path
Given an absolute path for a file (Unix-style), simplify it.For example,path = "/home/", => "/home"path = "/a/./b/../../c/", => "/c"click to show corner cases.Corner Cases:Did
2017-08-08 10:32:14
201
原创 128. Longest Consecutive Sequence
Given an unsorted array of integers, find the length of the longest consecutive elements sequence.For example,Given [100, 4, 200, 1, 3, 2],The longest consecutive elements sequence is [1, 2, 3
2017-08-07 10:16:18
204
原创 322. Coin Change
You are given coins of different denominations and a total amount of money amount. Write a function to compute the fewest number of coins that you need to make up that amount. If that amount of money
2017-08-07 09:51:26
152
原创 80. Remove Duplicates from Sorted Array II
Follow up for "Remove Duplicates":What if duplicates are allowed at most twice?For example,Given sorted array nums = [1,1,1,2,2,3],Your function should return length = 5, with the first fi
2017-08-05 23:42:35
116
原创 26. Remove Duplicates from Sorted Array
Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length.Do not allocate extra space for another array, you must do this in place with
2017-08-05 22:40:01
112
原创 15. 3Sum
Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.Note: The solution set must not contain
2017-08-04 09:52:31
138
原创 1. Two Sum
Given an array of integers, return indices of the two numbers such that they add up to a specific target.You may assume that each input would have exactly one solution, and you may not use the sam
2017-08-04 09:45:17
174
原创 648. Replace Words
In English, we have a concept called root, which can be followed by some other words to form another longer word - let's call this word successor. For example, the root an, followed by other, whic
2017-08-03 20:19:40
171
原创 70. Climbing Stairs
You are climbing a stair case. It takes n steps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?題意:有一個梯子,一次只能爬1階或2階,那有幾種方式可以
2017-08-03 19:42:56
140
原创 62. Unique Paths
A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below).The robot can only move either down or right at any point in time. The robot is trying to reach the
2017-08-03 10:10:29
200
原创 215. Kth Largest Element in an Array
Find the kth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct element.For example,Given [3,2,1,5,6,4] and k = 2, return 5.
2017-08-03 09:59:53
266
原创 257. Binary Tree Paths
Given a binary tree, return all root-to-leaf paths.For example, given the following binary tree: 1 / \2 3 \ 5All root-to-leaf paths are:["1->2->5", "1->3"]題意:
2017-08-02 20:17:52
142
原创 213. House Robber II
Note: This is an extension of House Robber.After robbing those houses on that street, the thief has found himself a new place for his thievery so that he will not get too much attention. This time
2017-08-02 14:26:03
176
原创 46. Permutations
Given a collection of distinct 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], [3,2,1]
2017-08-02 10:40:44
157
原创 100. Same Tree
Given two binary trees, write a function to check if they are equal or not.Two binary trees are considered equal if they are structurally identical and the nodes have the same value.題意:給定兩顆二叉樹
2017-08-02 10:23:15
226
原创 189. Rotate Array
Rotate an array of n elements to the right by k steps.For example, with n = 7 and k = 3, the array [1,2,3,4,5,6,7] is rotated to [5,6,7,1,2,3,4].Note:Try to come up as many solutions as yo
2017-08-02 09:57:22
148
原创 198. House Robber
You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is that adjacent house
2017-08-02 09:51:56
166
原创 216. Combination Sum III
Find all possible combinations of k numbers that add up to a number n, given that only numbers from 1 to 9 can be used and each combination should be a unique set of numbers.Example 1:Input:
2017-08-01 20:34:16
188
原创 40. Combination Sum II
Given a collection of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T.Each number in C may only be used once in the combinati
2017-08-01 20:30:16
193
原创 39. Combination Sum
Given a set of candidate numbers (C) (without duplicates) 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 fr
2017-08-01 17:49:11
167
原创 77. Combinations
Given two integers n and k, return all possible combinations of k numbers out of 1 ... n.For example,If n = 4 and k = 2, a solution is:[ [2,4], [3,4], [
2017-08-01 16:25:26
204
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人