刷题
文章平均质量分 50
beginner_and_go
这个作者很懒,什么都没留下…
展开
-
Hold住Leetcode——First Bad Version
You are a product manager and currently leading a team to develop a new product. Unfortunately, the latest version of your product fails the quality check. Since each version is developed based on the原创 2017-05-22 19:34:36 · 218 阅读 · 0 评论 -
Hold住Leetcode——Arranging Coins
题目的意思是:给一个整数,将其分解成从1开始连续的几个数相加,返回那个最大的数。n = 5The coins can form the following rows:¤¤ ¤¤ ¤Because the 3rd row is incomplete, we return 2.n = 8The coins can form the following rows:¤¤ ¤¤原创 2017-05-21 19:39:21 · 214 阅读 · 0 评论 -
Hold住Leetcode——Intersection of Two Arrays II
Given two arrays, write a function to compute their intersection.Example:Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2, 2].Note:Each element in the result should appear as many tim原创 2017-05-23 15:05:31 · 270 阅读 · 0 评论 -
Hold住Leetcode——Intersection of Two Arrays
Given two arrays, write a function to compute their intersection.Example:Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2].Note:Each element in the result must be unique.The result原创 2017-05-23 19:40:31 · 242 阅读 · 0 评论 -
Hold住Leetcode——Submission Details
Given four lists A, B, C, D of integer values, compute how many tuples (i, j, k, l) there are such that A[i] + B[j] + C[k] + D[l] is zero.To make problem a bit easier, all A, B, C, D have same l原创 2017-05-25 15:08:55 · 529 阅读 · 0 评论 -
Hold住Leetcode
Given a positive integer num, write a function which returns True if num is a perfect square else False.判断输入的值是不是平方值,不能用sqrt()函数Example 1:Input: 16Returns: TrueExample 2:Inpu原创 2017-05-19 17:10:31 · 245 阅读 · 0 评论 -
Hold住Leetcode——Two Sum II - Input array is sorted
题目的意思是找出容器中的两个值,使他们相加等于目标值,返回这两个值的索引。值得注意的是:容器中的数值是按顺序排列的一看到题目首先想到的就是二重循环的,结果这样就会超时class Solution {public: vector twoSum(vector& numbers, int target) { int size=numbers.size(); int原创 2017-05-21 17:07:03 · 218 阅读 · 0 评论 -
Hold住Leetcode—— Sqrt(x)
自己实现开方函数思路:使用二分查找的思想,找到中间值,如果中间值的平方数大于目标值的话,那么将二分的右端点赋为中间值减1,不断循环,肯定可以定位到中间值的平方小于目标值的情况此时,判断中间值+1的平方是不是大于目标值,如果是,那么就返回此时的中间值,否,就将二分的左端点赋为中间值加1,再继续判断。class Solution {public: int mySqrt(int x) {原创 2017-05-22 11:33:56 · 167 阅读 · 0 评论