- 博客(15)
- 收藏
- 关注
原创 29. Divide Two Integers
Divide two integers without using multiplication, division and mod operator.If it is overflow, return MAX_INT.求两个数的商,要求不能用乘法,除法和求模的运算,那就要用位运算,求商相当于求分母含有多少个分子(最后剩下的比分子小的不算),如果用直接的搜索方法(即分子
2016-09-18 09:30:02 131
原创 35. Search Insert Position
Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.You may assume no duplicates in the array.
2016-09-18 08:48:26 148
原创 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 du
2016-09-10 10:03:42 143
原创 383. Ransom Note
Given an arbitrary ransom note string and another string containing letters from all the magazines, write a function that will return true if the ransom note can be construc
2016-09-09 22:32:04 535
原创 Centos7 安装opencv
opencv是个跨平台计算机视觉库,很久之前就对opencv感兴趣了,但是由于以前用的是centos6.8,各种依赖项都是版本太老,安装起来十分费尽(glib,gtk+什么的更新无力)。直到现在更新到了centos7,终于安装成功了。在此把安装过程记录下来。安装方法参考了CentOS7配置opencv for python && eclipse c/c++在安装之前,要先配置好epel
2016-09-09 19:16:11 16473 6
原创 357. Count Numbers with Unique Digits
Given a non-negative integer n, count all numbers with unique digits, x, where 0 ≤ x n.Example:Given n = 2, return 91. (The answer should be the total numbers in the range of 0 ≤ x [11,22,33,44,
2016-09-09 10:13:19 278
原创 389. Find the Difference
Given two strings s and t which consist of only lowercase letters.String t is generated by random shuffling string s and then add one more letter at a random position.Find the letter that was
2016-09-09 09:13:25 190
原创 371. Sum of Two Integers
Calculate the sum of two integers a and b, but you are not allowed to use the operator + and -.Example:Given a = 1 and b = 2, return 3.不用+和-运算符,求a和b的和。用为运算的方法。根据a+b = a^b + (a&b),用递归的方法求和即
2016-09-08 23:27:08 108
原创 352. Data Stream as Disjoint Intervals
Given a data stream input of non-negative integers a1, a2, ..., an, ..., summarize the numbers seen so far as a list of disjoint intervals.For example, suppose the integers from the data stream are
2016-09-08 22:50:39 214
原创 39. Combination Sum
Given a set of candidate numbers (C) and a target number (T), find all unique combinations inC where the candidate numbers sums to T.The same repeated number may be chosen from C unlimited numbe
2016-09-08 21:54:00 147
原创 129. Sum Root to Leaf Numbers
Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a number.An example is the root-to-leaf path 1->2->3 which represents the number 123.Find the tota
2016-09-08 16:45:14 207
原创 146. 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 value (will always be positive) of the key if
2016-09-08 15:58:38 209
原创 1010. Lehmer Code (35)
According to Wikipedia: "In mathematics and in particular in combinatorics, theLehmer code is a particular way to encode each possible permutation of a sequence ofn numbers." To be more specific,
2016-09-07 15:57:33 681
原创 149. Max Points on a Line
Given n points on a 2D plane, find the maximum number of points that lie on the same straight line.给出若干个点,求出最多的点使得这些点共线,输出点数。对于每一个点,视当前点为起点,到各个点的直线斜率相等的话就是共线,用map记录共线的点的数目,要注意点相同时和两个点连成的直线斜率不存
2016-09-04 17:28:02 182
原创 135. 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 requirements:Each child must have at least on
2016-09-04 16:44:01 208
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人