随笔分类 -  LeetCode

摘要:题意 Implement pow(x, n). 求X的N次方。 解法 用正常的办法来做是会超时的,因为可能有21亿次方的情况,所以需要优化一下。这里用到了 算法,简单来说就是将指数分解成二进制的形式,比如X的7次方,就可以表示成 ,这里将7分解成了 的形式,这样做之后,乘法就只需要进行三次,所以要做 阅读全文
posted @ 2016-10-09 18:12 Decouple 阅读(539) 评论(0) 推荐(0) 编辑
摘要:题意 Given a collection of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T. Each 阅读全文
posted @ 2016-09-21 13:56 Decouple 阅读(203) 评论(0) 推荐(0) 编辑
摘要:题意 Given a set of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T. The same rep 阅读全文
posted @ 2016-09-21 13:31 Decouple 阅读(183) 评论(0) 推荐(0) 编辑
摘要:题意 The count and say sequence is the sequence of integers beginning as follows: 1, 11, 21, 1211, 111221, ... 1 is read off as "one 1" or 11. 11 is rea 阅读全文
posted @ 2016-09-20 20:28 Decouple 阅读(193) 评论(0) 推荐(0) 编辑
摘要:题意 Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in 阅读全文
posted @ 2016-09-20 18:30 Decouple 阅读(243) 评论(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 阅读全文
posted @ 2016-09-20 18:16 Decouple 阅读(241) 评论(0) 推荐(0) 编辑
摘要:题意 Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers. If such arrangement is not pos 阅读全文
posted @ 2016-09-20 18:11 Decouple 阅读(177) 评论(0) 推荐(0) 编辑
摘要:题意 Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity. 将K个排好序的链表合并成一个 解法 和之前合并两个有序链表那题不同,那题用的是两个指针来分别记录 阅读全文
posted @ 2016-09-10 18:22 Decouple 阅读(223) 评论(0) 推荐(0) 编辑
摘要:题意 Given n pairs of parentheses, write a function to generate all combinations of well formed parentheses. For example, given n = 3, a solution set is 阅读全文
posted @ 2016-09-10 17:48 Decouple 阅读(283) 评论(0) 推荐(0) 编辑
摘要:题意 Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = target? Find all unique quadruplets in the array w 阅读全文
posted @ 2016-09-09 17:05 Decouple 阅读(214) 评论(0) 推荐(0) 编辑
摘要:题意 Given a digit string, return all possible letter combinations that the number could represent. A mapping of digit to letters (just like on the tele 阅读全文
posted @ 2016-09-09 16:43 Decouple 阅读(256) 评论(0) 推荐(0) 编辑
摘要:题意 Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Return the sum of the three intege 阅读全文
posted @ 2016-09-09 15:50 Decouple 阅读(209) 评论(0) 推荐(0) 编辑
摘要:题意 Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum 阅读全文
posted @ 2016-09-09 15:31 Decouple 阅读(361) 评论(0) 推荐(0) 编辑
摘要:题意 Given n non negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two en 阅读全文
posted @ 2016-05-11 20:25 Decouple 阅读(242) 评论(0) 推荐(0) 编辑
摘要:题意 Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters 阅读全文
posted @ 2016-03-30 18:03 Decouple 阅读(258) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示