摘要: Given an array of integers, find two numbers such that they add up to a specific target number. The function twoSum should return indices of the two n 阅读全文
posted @ 2017-07-20 20:13 王大咩的图书馆 阅读(237) 评论(0) 推荐(0) 编辑
摘要: Given an index k, return the k th row of the Pascal's triangle. For example, given k = 3,Return[1,3,3,1]. Note: Could you optimize your algorithm to u 阅读全文
posted @ 2017-07-20 16:35 王大咩的图书馆 阅读(192) 评论(0) 推荐(0) 编辑
摘要: Given numRows, generate the first numRows of Pascal's triangle. For example, given numRows = 5,Return 题意:给定行数构建帕斯卡三角。 思路:注意行数和该行中列数的关系,还有每行中非首尾元素时,该元素 阅读全文
posted @ 2017-07-20 15:40 王大咩的图书馆 阅读(130) 评论(0) 推荐(0) 编辑
摘要: Divide two integers without using multiplication, division and mod operator. 题意:两数相除不能用乘法、除、取余运算。 思路:直观的想法是相减,使用计算器p记下相减的次数n,这样时间复杂度为O(n)(n代表相减次数)。这是如 阅读全文
posted @ 2017-07-20 15:17 王大咩的图书馆 阅读(364) 评论(0) 推荐(0) 编辑