摘要: Given an integer n, return the number of trailing zeroes in n!. Note: Your solution should be in logarithmic time complexity. 要求时间复杂度为log型 int trailingZeroes(int n) { int ret = 0; while(n) ... 阅读全文
posted @ 2015-10-27 09:19 dylqt 阅读(110) 评论(0) 推荐(0) 编辑
摘要: Given two binary strings, return their sum (also a binary string).For example,a = "11"b = "1"Return "100".char* addBinary(char* a, char* b) { int a... 阅读全文
posted @ 2015-10-26 17:20 dylqt 阅读(135) 评论(0) 推荐(0) 编辑
摘要: Find the total area covered by two rectilinear rectangles in a 2D plane. Each rectangle is defined by its bottom left corner and top right corner as shown in the figure. Assume that the total area is... 阅读全文
posted @ 2015-10-25 08:58 dylqt 阅读(151) 评论(0) 推荐(0) 编辑
摘要: Given numRows, generate the first numRows of Pascal's triangle. For example, given numRows = 5,Return[ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1] ] class Solution { public: vector... 阅读全文
posted @ 2015-10-24 10:49 dylqt 阅读(95) 评论(0) 推荐(0) 编辑
摘要: Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array. Note:You may assume that nums1 has enough space (size that is greater or equal to m + n) to hold additional... 阅读全文
posted @ 2015-10-23 21:29 dylqt 阅读(134) 评论(0) 推荐(0) 编辑
摘要: Given a non-negative number represented as an array of digits, plus one to the number. The digits are stored such that the most significant digit is at the head of the list. 用一个数组中的每个值连起来作为一个数,把这个数加1... 阅读全文
posted @ 2015-10-23 09:09 dylqt 阅读(120) 评论(0) 推荐(0) 编辑
摘要: 一、概述1、面向对象程序设计的核心思想:数据抽象、继承和动态绑定数据抽象:将类的接口与实现分离继承:可以定义相似的类型并对相似关系建模动态绑定:可以一定程度上忽略类似类型的区别,而以同一的方式使用它们的对象2、当使用基类的引用(或指针)调用一个虚函数时将发生动态绑定二、虚函数1、基类希望它的派生类各... 阅读全文
posted @ 2015-10-22 21:01 dylqt 阅读(158) 评论(0) 推荐(0) 编辑
摘要: Determine if a Sudoku is valid, according to: Sudoku Puzzles - The Rules. The Sudoku board could be partially filled, where empty cells are filled with the character '.'. A partially filled sudoku ... 阅读全文
posted @ 2015-10-18 13:35 dylqt 阅读(105) 评论(0) 推荐(0) 编辑
摘要: Description: Count the number of prime numbers less than a non-negative number, n. 找出小于n的质数的和 int countPrimes(int n) { int count = 0; if(n num(n - 1, true); num[0] = false; ... 阅读全文
posted @ 2015-10-18 09:23 dylqt 阅读(161) 评论(0) 推荐(0) 编辑
摘要: Given an array of integers and an integer k, find out whether there are two distinct indices i and j in the array such that nums[i] = nums[j] and the difference between i and jis at most k. class So... 阅读全文
posted @ 2015-10-17 18:54 dylqt 阅读(122) 评论(0) 推荐(0) 编辑