上一页 1 2 3 4 5 6 7 8 9 10 ··· 23 下一页
摘要: Write a program to check whether a given number is an ugly number.Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For exam... 阅读全文
posted @ 2015-09-11 15:08 vincently 阅读(158) 评论(0) 推荐(0) 编辑
摘要: Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one that is missing from the array.For example,Given nums = [0, 1, 3... 阅读全文
posted @ 2015-09-11 14:48 vincently 阅读(151) 评论(0) 推荐(0) 编辑
摘要: Follow up for "Unique Paths":Now consider if some obstacles are added to the grids. How many unique paths would there be?An obstacle and empty space i... 阅读全文
posted @ 2015-09-11 10:31 vincently 阅读(144) 评论(0) 推荐(0) 编辑
摘要: A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below).The robot can only move either down or right at any po... 阅读全文
posted @ 2015-09-10 21:48 vincently 阅读(106) 评论(0) 推荐(0) 编辑
摘要: You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping yo... 阅读全文
posted @ 2015-09-10 21:18 vincently 阅读(157) 评论(0) 推荐(0) 编辑
摘要: Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path.N... 阅读全文
posted @ 2015-09-10 15:29 vincently 阅读(171) 评论(0) 推荐(0) 编辑
摘要: Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties:Integers in each row are sorted fr... 阅读全文
posted @ 2015-09-05 21:00 vincently 阅读(158) 评论(0) 推荐(0) 编辑
摘要: 题目来源:写一个函数,求两个整数之和,要求在函数体内不得使用+、-、×、÷四则运算符号。 分析:对于5+17=22.我们可以分三步进行:第一步只做各位相加不进位,此时相加的结果是12(个位数5和7中有进位,进位的值是10);第二步做进位,5+7中有进位,进位的值是10;第三步把前面两个结果加起... 阅读全文
posted @ 2015-09-05 20:08 vincently 阅读(206) 评论(0) 推荐(0) 编辑
摘要: 题目来源:《编程之美》2.10 题目:同时找出数组中的最大数和最小数 分析:最基本的方法是两次线性扫描数组,分别找出最大数和最小数,时间复杂度为O(n)。其实我们可以一次扫描即可。首先,我们将输入元素相互进行比较,然后把较小的与当前最小值比较,把较大的与当前最大值进行比较。这样,对每两个元素... 阅读全文
posted @ 2015-09-05 10:38 vincently 阅读(1695) 评论(0) 推荐(0) 编辑
摘要: 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 ord... 阅读全文
posted @ 2015-09-04 22:03 vincently 阅读(160) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 8 9 10 ··· 23 下一页