随笔分类 -  算法刷题

record the solution on the leetcode platform
摘要:前言: 二分搜索是一个非常常见的面试题目,它具有非常广泛的用途。熟练的掌握二分搜索的基本形式和他的变式是非常重要的。接下来我们将使用java实现一些常见的有关二分搜索的问题。 具体内容: 1.二分搜索的基本形式:在一个有序的数组中查找k,如果k存在的话就返回k的下标,否则就返回-1 基本的二分搜索要 阅读全文
posted @ 2018-05-09 21:10 whatyouknow123 阅读(445) 评论(0) 推荐(0)
摘要:Description: Given an index k, return the kth row of the Pascal's triangle. For example, given k = 3,Return [1,3,3,1]. Note:Could you optimize your al 阅读全文
posted @ 2017-10-16 22:07 whatyouknow123 阅读(405) 评论(0) 推荐(0)
摘要:Description: Given numRows, generate the first numRows of Pascal's triangle. For example, given numRows = 5,Return 第二种想法:第i行有i个数;每次往最前面插入一个1,那么除了头尾以外, 阅读全文
posted @ 2017-10-15 22:50 whatyouknow123 阅读(480) 评论(0) 推荐(0)
摘要:Description: Find the contiguous subarray within an array (containing at least one number) which has the largest sum. For example, given the array [-2 阅读全文
posted @ 2017-10-13 22:19 whatyouknow123 阅读(148) 评论(0) 推荐(0)
摘要:Description: Given an array and a value, remove all instances of that value in place and return the new length. Do not allocate extra space for anothe 阅读全文
posted @ 2017-10-09 09:24 whatyouknow123 阅读(138) 评论(0) 推荐(0)
摘要:description: Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x. You should 阅读全文
posted @ 2017-09-18 11:14 whatyouknow123 阅读(117) 评论(0) 推荐(0)
摘要:description: Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string. If 阅读全文
posted @ 2017-09-16 16:01 whatyouknow123 阅读(255) 评论(0) 推荐(0)
摘要:description: Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers. If such arrangement 阅读全文
posted @ 2017-09-15 09:39 whatyouknow123 阅读(141) 评论(0) 推荐(0)
摘要:description: Follow up for "Search in Rotated Sorted Array":What if duplicates are allowed? Would this affect the run-time complexity? How and why? Su 阅读全文
posted @ 2017-09-12 14:24 whatyouknow123 阅读(125) 评论(0) 推荐(0)
摘要:Description: Given a collection of numbers that might contain duplicates, return all possible unique permutations. For example,[1,1,2] have the follow 阅读全文
posted @ 2017-09-11 10:51 whatyouknow123 阅读(169) 评论(0) 推荐(0)
摘要:Description: Given a collection of distinct numbers, return all possible permutations. For example,[1,2,3] have the following permutations: [ [1,2,3], 阅读全文
posted @ 2017-09-10 16:36 whatyouknow123 阅读(165) 评论(0) 推荐(0)
摘要:Description: Given a collection of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums t 阅读全文
posted @ 2017-09-09 09:28 whatyouknow123 阅读(162) 评论(0) 推荐(0)
摘要:Descirption: Given a set of candidate numbers (C) (without duplicates) and a target number (T), find all unique combinations in C where the candidate 阅读全文
posted @ 2017-09-09 09:09 whatyouknow123 阅读(126) 评论(0) 推荐(0)
摘要:description: Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length. Do not allocate e 阅读全文
posted @ 2017-09-07 09:42 whatyouknow123 阅读(156) 评论(0) 推荐(0)
摘要:Description: Write a function to find the longest common prefix string amongst an array of strings. Thoughts: 1.定义一个结果字符串result=""; 2.如果List的长度为0,那么直接 阅读全文
posted @ 2017-09-06 09:10 whatyouknow123 阅读(153) 评论(0) 推荐(0)
摘要:problem description: given a sorted aescend array,return the begining and ending position of the target num i.e: [1,2,3,8,8,9] return [3,4] of course, 阅读全文
posted @ 2017-04-24 22:25 whatyouknow123 阅读(173) 评论(0) 推荐(0)
摘要:descripte problem: there is an array,at the first it is sorted,but for som reason, it was rotated at some pivot unknown to you beforehand.then you sho 阅读全文
posted @ 2017-04-24 09:52 whatyouknow123 阅读(122) 评论(0) 推荐(0)
摘要:problem description: there is four number list named A,B,C,D; now you should out put the num of tuples which statisfy A[i] +B[j]+C[k]+D[l] =0 i.e: 以上的 阅读全文
posted @ 2017-04-23 22:04 whatyouknow123 阅读(162) 评论(0) 推荐(0)
摘要:problem description: remove the nth node from the end of the list for example: given: 1->2->3 n = 1 return: 1->2 thought: first:you should know the le 阅读全文
posted @ 2017-04-18 10:01 whatyouknow123 阅读(173) 评论(0) 推荐(0)
摘要:problem description: this is the addition about the 3sum,you can use the method of solve the 3sum. given a integer and the target,you should return th 阅读全文
posted @ 2017-04-18 09:55 whatyouknow123 阅读(127) 评论(0) 推荐(0)