- 博客(51)
- 资源 (3)
- 收藏
- 关注
原创 实习面试经验
上周面了一家其实和我本行业有很大渊源的C公司,写些东西来记录一下。插曲,送简历的时候不小心把他们公司的名称给拼错了,最后还是给了面试机会,也觉得还挺走运的。面的是软件开发实习生,总时间长度是一个小时,两个人一起电话面我。首先自我介绍。由于说了简历实在太单薄,不知道怎么扯到了树的遍历。1、深度遍历非递归写法需要哪种数据结构?为什么?我答的是栈,因为要把父节点压栈,栈有先进后出
2016-04-30 22:21:59 272
原创 343. Integer Break
Given a positive integer n, break it into the sum of at least two positive integers and maximize the product of those integers. Return the maximum product you can get.For example, given n = 2, retur
2016-04-30 22:05:12 190
原创 42. Trapping Rain Water
Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining.For example, Given [0,1,0,2,1,0,1,3,2,1,2,1]
2016-04-30 15:18:19 185
原创 139. Word Break 动态规划
Given a string s and a dictionary of words dict, determine ifs can be segmented into a space-separated sequence of one or more dictionary words.For example, givens = "leetcode",dict = ["leet",
2016-04-30 13:29:06 377
原创 117. 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 extr
2016-04-24 16:02:14 177
原创 154. Find Minimum in Rotated Sorted Array II
Follow up for "Find Minimum in Rotated Sorted Array":What if duplicates are allowed?Would this affect the run-time complexity? How and why?Suppose a sorted array is rotated at some pivot unkno
2016-04-24 15:32:27 196
原创 342. Power of Four
Given an integer (signed 32 bits), write a function to check whether it is a power of 4.Example:Given num = 16, return true.Given num = 5, return false.Follow up: Could you solve it without loop
2016-04-24 15:12:17 208
原创 345. Reverse Vowels of a String
Write a function that takes a string as input and reverse only the vowels of a string.Example 1:Given s = "hello", return "holle".Example 2:Given s = "leetcode", return "leotcede".Subscrib
2016-04-24 14:58:52 278
原创 287. Find the Duplicate Number
Given an array nums containing n + 1 integers where each integer is between 1 and n (inclusive), prove that at least one duplicate number must exist. Assume that there is only one duplicate number,
2016-04-23 14:00:48 197
原创 312. Burst Balloons dp
Given n balloons, indexed from 0 to n-1. Each balloon is painted with a number on it represented by arraynums. You are asked to burst all the balloons. If the you burst ballooni you will get nums[
2016-04-17 11:16:53 211
原创 241. Different Ways to Add Parentheses 分治法的应用
Given a string of numbers and operators, return all possible results from computing all the different possible ways to group numbers and operators. The valid operators are+, - and *.Example 1I
2016-04-15 19:08:54 253
原创 334. Increasing Triplet Subsequence 动态规划
Given an unsorted array return whether an increasing subsequence of length 3 exists or not in the array.Formally the function should:Return true if there exists i, j, k such that arr[i] arr[j]
2016-04-15 18:05:20 267
原创 166. Fraction to Recurring Decimal
Given two integers representing the numerator and denominator of a fraction, return the fraction in string format.If the fractional part is repeating, enclose the repeating part in parentheses.For
2016-04-15 12:19:44 156
原创 151. Reverse Words in a String
Given an input string, reverse the string word by word.For example,Given s = "the sky is blue",return "blue is sky the".Update (2015-02-12):For C programmers: Try to solve it in-place in O(1
2016-04-14 22:24:12 145
原创 220. Contains Duplicate III set的应用
Given an array of integers, find out whether there are two distinct indices i and j in the array such that the difference between nums[i] andnums[j] is at most t and the difference between i and
2016-04-13 21:54:04 174
原创 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:Elements in a triplet (a,b,c) m
2016-04-12 22:09:03 215
转载 128 Largest Number (自定义比较函数排序)
Given a list of non negative integers, arrange them such that they form the largest number.For example, given [3, 30, 34, 5, 9], the largest formed number is9534330.Note: The result may be very
2016-04-12 21:01:52 216
原创 98. 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.The
2016-04-12 16:12:10 175
原创 3. Longest Substring Without Repeating Characters 最长不重复序列
Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters for "abcabcbb" is "abc", which the length is 3. For
2016-04-12 15:29:26 186
原创 152. Maximum Product Subarray 动态规划
Find the contiguous subarray within an array (containing at least one number) which has the largest product.For example, given the array [2,3,-2,4],the contiguous subarray [2,3] has the largest pr
2016-04-10 19:21:47 209
原创 304. Range Sum Query 2D - Immutable 动态规划
Given a 2D matrix matrix, find the sum of the elements inside the rectangle defined by its upper left corner (row1,col1) and lower right corner (row2, col2).The above rectangle (with the red bor
2016-04-10 15:51:36 224
原创 54. Spiral Matrix
Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order.For example,Given the following matrix:[ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8, 9 ]]You
2016-04-10 12:25:57 170
原创 2. Add Two Numbers
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 numbers and return it as a link
2016-04-10 10:20:01 178
原创 61. Rotate List
Given a list, rotate the list to the right by k places, where k is non-negative.For example:Given 1->2->3->4->5->NULL and k = 2,return 4->5->1->2->3->NULL.Subscribe to see which companies as
2016-04-10 10:03:22 168
原创 5. Longest Palindromic Substring 动态规划
Given a string S, find the longest palindromic substring in S. You may assume that the maximum length ofS is 1000, and there exists one unique longest palindromic substring.问题分析:求最长回文子字符串。参考注意
2016-04-09 22:16:22 816 1
原创 43. Multiply Strings 字符串乘
Given two numbers represented as strings, return multiplication of the numbers as a string.Note: The numbers can be arbitrarily large and are non-negative.Subscribe to see which companies asked
2016-04-09 16:20:22 239
原创 150. Evaluate Reverse Polish Notation 逆波兰式
Evaluate the value of an arithmetic expression in Reverse Polish Notation.Valid operators are +, -, *, /. Each operand may be an integer or another expression.Some examples: ["2", "1", "+",
2016-04-09 14:31:15 186
原创 96. Unique Binary Search Trees 动态规划
Given n, how many structurally unique BST's (binary search trees) that store values 1...n?For example,Given n = 3, there are a total of 5 unique BST's. 1 3 3 2 1 \
2016-04-09 13:31:23 150
原创 18. 4Sum
Given an array S of n integers, are there elements a,b, c, and d in S such that a + b +c + d = target? Find all unique quadruplets in the array which gives the sum of target.Note:Elements
2016-04-09 12:15:30 165
原创 227. Basic Calculator II
Implement a basic calculator to evaluate a simple expression string.The expression string contains only non-negative integers, +, -, *, / operators and empty spaces. The integer division should
2016-04-07 21:33:16 246
原创 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 mone
2016-04-07 18:43:57 345
原创 222. Count Complete Tree Nodes 完全二叉树节点
Given a complete binary tree, count the number of nodes.Definition of a complete binary tree from Wikipedia:In a complete binary tree every level, except possibly the last, is completely filled,
2016-04-06 22:20:31 261
原创 87. Repeated DNA Sequences
All DNA is composed of a series of nucleotides abbreviated as A, C, G, and T, for example: "ACGAATTCCG". When studying DNA, it is sometimes useful to identify repeated sequences within the DNA.Write
2016-04-06 21:03:33 117
原创 69. Sqrt(x)
Implement int sqrt(int x).Compute and return the square root of x.Subscribe to see which companies asked this question分析:数学方法解答。很奇怪我的不能用平常算法写完。参照别的。代码:class Solution {public: int
2016-04-06 19:34:54 195
原创 229. Majority Element II
Given an integer array of size n, find all elements that appear more than⌊ n/3 ⌋ times. The algorithm should run in linear time and in O(1) space.最多只会有两个数,运用数据结构与算法中求中位数的方法。注意第一个数 取nums[0],第二个数需
2016-04-03 18:59:01 184
原创 31. Next Permutation 冒泡排序应用
Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.If such arrangement is not possible, it must rearrange it as the lowest possible o
2016-04-03 18:13:03 146
原创 209. Minimum Size Subarray Sum
Given an array of n positive integers and a positive integer s, find the minimal length of a subarray of which the sum ≥ s. If there isn't one, return 0 instead.For example, given the array [2,3,1
2016-04-03 17:38:22 153
原创 210. Course Schedule II 图的dfs算法
There are a total of n courses you have to take, labeled from 0 ton - 1.Some courses may have prerequisites, for example to take course 0 you have to first take course 1, which is expressed as a p
2016-04-03 17:35:23 205
原创 207. Course Schedule 图的dfs算法
There are a total of n courses you have to take, labeled from 0 ton - 1.Some courses may have prerequisites, for example to take course 0 you have to first take course 1, which is expressed as a p
2016-04-03 14:32:42 248
原创 82. Remove Duplicates from Sorted List II
Given a sorted linked list, delete all nodes that have duplicate numbers, leaving onlydistinct numbers from the original list.For example,Given 1->2->3->3->4->4->5, return 1->2->5.Given 1->1->
2016-04-02 21:30:52 220
python xlrd3 安装包 用于python3以后的版本
2016-07-27
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人