摘要:
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 阅读全文
摘要:
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 阅读全文
摘要:
Given numRows, generate the first numRows of Pascal's triangle. For example, given numRows = 5,Return 题意:给定行数构建帕斯卡三角。 思路:注意行数和该行中列数的关系,还有每行中非首尾元素时,该元素 阅读全文
摘要:
Divide two integers without using multiplication, division and mod operator. 题意:两数相除不能用乘法、除、取余运算。 思路:直观的想法是相减,使用计算器p记下相减的次数n,这样时间复杂度为O(n)(n代表相减次数)。这是如 阅读全文