- 博客(28)
- 资源 (1)
- 收藏
- 关注
原创 leetcode 059 Spiral Matrix II
Given an integer n, generate a square matrix filled with elements from 1 to n2 in spiral order.For example,Given n = 3,You should return the following matrix:[ [ 1, 2, 3 ], [ 8, 9, 4 ], [
2016-04-30 17:31:37 233
原创 leetcode 058 Length of Last Word
Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.If the last word does not exist, return 0.Note: A word is
2016-04-30 17:11:22 216
原创 leetcode 055 Jump Game
Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximum jump length at that position.Determine i
2016-04-30 16:40:50 278
原创 leetcode 054 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 sho
2016-04-30 16:12:39 237
原创 leetcode 053 Maximum Subarray
Find the contiguous subarray within an array (containing at least one number) which has the largest sum.For example, given the array [−2,1,−3,4,−1,2,1,−5,4],the contiguous subarray [4,−1,2,1] ha
2016-04-30 15:32:41 239
原创 leetcode 050 Pow(x, n)
Implement pow(x, n).Subscribe to see which companies asked this questionclass Solution {public: double myPow(double x, int n) { double ans = 1.0; double temp = x; bool flag =
2016-04-30 14:53:34 239
原创 leetcode 048 Rotate Image
You are given an n x n 2D matrix representing an image.Rotate the image by 90 degrees (clockwise).Follow up:Could you do this in-place?Subscribe to see which companies asked this que
2016-04-29 22:14:55 236
原创 leetcode 047 Permutations II
Given a collection of numbers that might contain duplicates, return all possible unique permutations.For example,[1,1,2] have the following unique permutations:[1,1,2], [1,2,1], and [2,1,1].
2016-04-29 19:42:28 224
原创 leetcode 046 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], and [3,2,1].
2016-04-27 21:28:51 238
原创 leetcode 043 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.Converting the input string to integ
2016-04-26 20:48:58 227
原创 leetcode 040 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 combina
2016-04-26 12:31:20 251
原创 leetcode 39 Combination Sum
Given a set of candidate numbers (C) 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 from C unlimited numb
2016-04-25 22:12:57 200
原创 leetcode 038 Count and Say
The count-and-say sequence is the sequence of integers beginning as follows:1, 11, 21, 1211, 111221, ...1 is read off as "one 1" or 11.11 is read off as "two 1s" or 21.21 is read off as
2016-04-25 20:49:11 215
原创 深度学习计算模型中"门函数"的作用
上面是LSTM的计算公式,那三个Sigmoid作为非线性函数的就是三个门。LSTM是RNN模型,决定t时刻节点的除了当前x(t)外,还有t-1时刻的隐层节点输出h(t-1).这代表了历史信息对当前的影响,所以决定门开关程度的除了当前输入x(t)外,还有h(t-1)。含义很清楚,输入门是用来控制输入i'(t)进出多少或者是否允许进出门的设备;输出门是用来控制t时刻状态值m(t)对外多少是
2016-04-24 16:14:05 5668
原创 扩展欧几里得算法
现在有两个数a,b,要求a,b的最大公约数。欧几里得是个十分有用的定理:gcd(a,b) = gcd(b,a%b)int gcd(int a, int b) { if(b == 0) return a; else return gcd(b,a%b);}扩展欧几里得:现在知道了a和b的最大公约数是gcd,那么,我们一定能找到这样的x和y,使得:a*x+b*y=gcd。有多解是一定的
2016-04-23 21:39:11 261
原创 leetcode 035 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-04-19 22:36:30 209
原创 leetcode 034 Search for a Range
Given a sorted array of integers, find the starting and ending position of a given target value.Your algorithm's runtime complexity must be in the order of O(log n).If the target is not found
2016-04-19 22:03:04 278
原创 leetcode 031 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
2016-04-18 22:58:49 174
原创 Sql语句优化注意
1.尽量不要对列名进行函数处理,而是针对后面的值进行处理例如 where col1=-5的效率比where -col1=5的效率要高。因为后面的条件对列值进行了计算。这样的条件下优化器无法使用索引,而是要针对所有值进行计算之后才能再比较2. 尽量使用和数据列一样的值进行操作如果col1是数值型,那么例如 where col1=2和where col1='2',则前者效率
2016-04-17 10:04:59 283
原创 SVM和logistics笔记
SVM的参数选择:C(1/lambda):Large C: lower bias,high variancesmall C,Higher bias, low variancesigma^2: Large sigma^2: Feature fi, vary more smoothlyHigher bias, lower variancesmall sigma^2: Feature
2016-04-13 23:26:36 469
原创 027 Remove Element
Given an array and a value, remove all instances of that value in place and return the new length.Do not allocate extra space for another array, you must do this in place with constant memory.
2016-04-08 23:16:45 198
原创 026 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
2016-04-06 21:46:19 196
原创 024 Swap Nodes in Pairs
Given a linked list, swap every two adjacent nodes and return its head.For example,Given 1->2->3->4, you should return the list as 2->1->4->3.Your algorithm should use only constant space. Y
2016-04-06 21:15:41 248
原创 022 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 set is:"((()))", "(()())", "(())()", "()(())", "()()
2016-04-05 23:28:03 200
原创 021 Merge Two Sorted Lists
Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists.Subscribe to see which companies asked this questio
2016-04-05 23:03:19 184
原创 016 3Sum Closest
Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Return the sum of the three integers. You may assume that each input would have exact
2016-04-04 20:31:48 221
原创 Association Rules and the apriori algorithm
Besides increasing sales profits, association rules can also be in other fields. In medical diagnosis for instance, understanding which symptoms tend to co-morbid can help to improve patient care and
2016-04-02 16:06:38 490
原创 Linux 命令 总结
sort 命令:-b 忽略每行前面开始出现的空格字符-c 检查文件是否已经按照顺序排序-f 排序时,忽略大小写字母-n 按照数值的大小排序-r 以相反的顺序来排序sort 将文件的每一行作为一个单位,相互比较,比较原则是从首字母向后,依次按照ASXII码值进行比较,最后将它们按升序输出。sort的-t选项和-k选项:假如一个文件有三列,列与列之间用冒
2016-04-02 08:53:30 318
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人