07 2014 档案

摘要:题目:Given a collection of integers that might contain duplicates, S, return all possible subsets.Note:Elements in a subset must be in non-descending o... 阅读全文
posted @ 2014-07-31 08:09 爱做饭的小莹子 阅读(3256) 评论(0) 推荐(0) 编辑
摘要:题目:Given a set of distinct integers, S, return all possible subsets.Note:Elements in a subset must be in non-descending order.The solution set must n... 阅读全文
posted @ 2014-07-31 04:21 爱做饭的小莹子 阅读(4660) 评论(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 @ 2014-07-31 03:57 爱做饭的小莹子 阅读(3466) 评论(0) 推荐(0) 编辑
摘要:题目:Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum.For example:Given the below binary tree and ... 阅读全文
posted @ 2014-07-31 03:21 爱做饭的小莹子 阅读(3455) 评论(1) 推荐(0) 编辑
摘要:题目:Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given su... 阅读全文
posted @ 2014-07-31 02:43 爱做饭的小莹子 阅读(3030) 评论(0) 推荐(1) 编辑
摘要:题目:Given a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined as a binary tree in which the d... 阅读全文
posted @ 2014-07-31 02:35 爱做饭的小莹子 阅读(2032) 评论(0) 推荐(0) 编辑
摘要:题目:Given an array where elements are sorted in ascending order, convert it to a height balanced BST.题解:先复习下什么是二叉搜索树(引自Wikipedia):二叉查找树(Binary Search ... 阅读全文
posted @ 2014-07-31 02:28 爱做饭的小莹子 阅读(3292) 评论(0) 推荐(1) 编辑
摘要:题目:Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root node down to the neares... 阅读全文
posted @ 2014-07-31 00:47 爱做饭的小莹子 阅读(3146) 评论(0) 推荐(0) 编辑
摘要:题目:Given a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthes... 阅读全文
posted @ 2014-07-31 00:25 爱做饭的小莹子 阅读(2348) 评论(0) 推荐(0) 编辑
摘要:题目:Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tree is symmetric: 1 /... 阅读全文
posted @ 2014-07-31 00:05 爱做饭的小莹子 阅读(3197) 评论(0) 推荐(0) 编辑
摘要:题目:Given two binary trees, write a function to check if they are equal or not.Two binary trees are considered equal if they are structurally identica... 阅读全文
posted @ 2014-07-30 23:44 爱做饭的小莹子 阅读(2420) 评论(0) 推荐(0) 编辑
摘要:题目:Given a binary tree, return the postorder traversal of its nodes' values.For example:Given binary tree {1,#,2,3}, 1 \ 2 / 3return [3... 阅读全文
posted @ 2014-07-30 09:53 爱做饭的小莹子 阅读(1731) 评论(0) 推荐(0) 编辑
摘要:题目:Given a binary tree, return the preorder traversal of its nodes' values.For example:Given binary tree {1,#,2,3}, 1 \ 2 / 3return [1,... 阅读全文
posted @ 2014-07-30 09:25 爱做饭的小莹子 阅读(1690) 评论(0) 推荐(0) 编辑
摘要:题目:Given a binary tree, return the inorder traversal of its nodes' values.For example:Given binary tree {1,#,2,3}, 1 \ 2 / 3return [1,3... 阅读全文
posted @ 2014-07-30 09:24 爱做饭的小莹子 阅读(2767) 评论(0) 推荐(0) 编辑
摘要:题目:Given two integers n and k, return all possible combinations of k numbers out of 1 ... n.For example,If n = 4 and k = 2, a solution is:[ [2,4], ... 阅读全文
posted @ 2014-07-30 09:18 爱做饭的小莹子 阅读(4441) 评论(0) 推荐(0) 编辑
摘要:题目:There are N children standing in a line. Each child is assigned a rating value. You are giving candies to these children subjected to the followin... 阅读全文
posted @ 2014-07-30 08:50 爱做饭的小莹子 阅读(1821) 评论(0) 推荐(0) 编辑
摘要:题目:Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after rain... 阅读全文
posted @ 2014-07-30 08:21 爱做饭的小莹子 阅读(3859) 评论(0) 推荐(0) 编辑
摘要:题目:Say you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may com... 阅读全文
posted @ 2014-07-30 05:23 爱做饭的小莹子 阅读(3159) 评论(0) 推荐(0) 编辑
摘要:题目:Say you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may com... 阅读全文
posted @ 2014-07-30 04:58 爱做饭的小莹子 阅读(2826) 评论(0) 推荐(0) 编辑
摘要:题目:Say you have an array for which the ith element is the price of a given stock on day i.If you were only permitted to complete at most one transact... 阅读全文
posted @ 2014-07-30 04:24 爱做饭的小莹子 阅读(1797) 评论(0) 推荐(0) 编辑
摘要:题目: Find the contiguous subarray within an array (containing at least one number) which has the largest sum.For example, given the array [−2,1,−3,4,−1... 阅读全文
posted @ 2014-07-30 04:06 爱做饭的小莹子 阅读(6336) 评论(0) 推荐(0) 编辑
摘要:题目:Given a string s and a dictionary of words dict, add spaces in s to construct a sentence where each word is a valid dictionary word.Return all suc... 阅读全文
posted @ 2014-07-30 02:49 爱做饭的小莹子 阅读(3390) 评论(0) 推荐(0) 编辑
摘要:题目:Given a string s and a dictionary of words dict, determine if s can be segmented into a space-separated sequence of one or more dictionary words.F... 阅读全文
posted @ 2014-07-29 09:27 爱做饭的小莹子 阅读(3062) 评论(0) 推荐(0) 编辑
摘要:题目:Given an array of strings, return all groups of strings that are anagrams.Note: All inputs will be in lower-case.题解:这道题看所给的字符串数组里面有多少个是同一个变形词变的。这道... 阅读全文
posted @ 2014-07-29 08:55 爱做饭的小莹子 阅读(3247) 评论(0) 推荐(0) 编辑
摘要:题目:Clone an undirected graph. Each node in the graph contains a label and a list of its neighbors.OJ's undirected graph serialization:Nodes are label... 阅读全文
posted @ 2014-07-29 05:29 爱做饭的小莹子 阅读(11051) 评论(3) 推荐(1) 编辑
摘要:题目:Given two sorted integer arrays A and B, merge B into A as one sorted array.Note:You may assume that A has enough space (size that is greater or e... 阅读全文
posted @ 2014-07-28 11:02 爱做饭的小莹子 阅读(1876) 评论(0) 推荐(0) 编辑
摘要:题目:Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n).For example,S = "ADOBE... 阅读全文
posted @ 2014-07-28 10:25 爱做饭的小莹子 阅读(5438) 评论(0) 推荐(0) 编辑
摘要:题目:You are given a string, S, and a list of words, L, that are all of the same length. Find all starting indices of substring(s) in S that is a conca... 阅读全文
posted @ 2014-07-28 10:05 爱做饭的小莹子 阅读(5444) 评论(2) 推荐(1) 编辑
摘要:题目:Given a set of non-overlapping intervals, insert a new interval into the intervals (merge if necessary).You may assume that the intervals were ini... 阅读全文
posted @ 2014-07-28 05:50 爱做饭的小莹子 阅读(3226) 评论(1) 推荐(0) 编辑
摘要:题目:Given a collection of intervals, merge all overlapping intervals.For example,Given [1,3],[2,6],[8,10],[15,18],return [1,6],[8,10],[15,18].题解:这道题主要... 阅读全文
posted @ 2014-07-28 05:31 爱做饭的小莹子 阅读(2971) 评论(0) 推荐(0) 编辑
摘要:题目:Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letter... 阅读全文
posted @ 2014-07-28 04:35 爱做饭的小莹子 阅读(2148) 评论(0) 推荐(0) 编辑
摘要:题目:Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.If the last w... 阅读全文
posted @ 2014-07-28 04:26 爱做饭的小莹子 阅读(2861) 评论(0) 推荐(0) 编辑
摘要:题目:Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your ma... 阅读全文
posted @ 2014-07-28 04:12 爱做饭的小莹子 阅读(2754) 评论(0) 推荐(0) 编辑
摘要:题目:Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your ma... 阅读全文
posted @ 2014-07-28 03:43 爱做饭的小莹子 阅读(2297) 评论(0) 推荐(0) 编辑
摘要:题目:Write a function to find the longest common prefix string amongst an array of strings.题解:解题思路是,先对整个String数组预处理一下,求一个最小长度(最长前缀肯定不能大于最小长度)。然后以第0个字符串... 阅读全文
posted @ 2014-07-28 03:33 爱做饭的小莹子 阅读(6206) 评论(0) 推荐(0) 编辑
摘要:题目:Given an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order r... 阅读全文
posted @ 2014-07-28 03:10 爱做饭的小莹子 阅读(3719) 评论(0) 推荐(0) 编辑
摘要:题目:Given an array and a value, remove all instances of that value in place and return the new length.The order of elements can be changed. It doesn't... 阅读全文
posted @ 2014-07-27 09:58 爱做饭的小莹子 阅读(2211) 评论(0) 推荐(0) 编辑
摘要:题目:Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length.Do not allocate extra space... 阅读全文
posted @ 2014-07-27 09:49 爱做饭的小莹子 阅读(3314) 评论(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 e... 阅读全文
posted @ 2014-07-27 09:26 爱做饭的小莹子 阅读(1943) 评论(0) 推荐(0) 编辑
摘要:题目:Divide two integers without using multiplication, division and mod operator.题解:这道题我自己没想出来。。。乘除取模都不让用。。那只有加减了。。。我参考的http://blog.csdn.net/perfect888... 阅读全文
posted @ 2014-07-27 09:12 爱做饭的小莹子 阅读(4028) 评论(2) 推荐(0) 编辑
摘要:题目:Follow up for N-Queens problem.Now, instead outputting board configurations, return the total number of distinct solutions.题解:这道题跟NQueens的解法完全一样(具... 阅读全文
posted @ 2014-07-27 04:49 爱做饭的小莹子 阅读(2498) 评论(0) 推荐(0) 编辑
摘要:题目:The n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other.Given an integer n, return a... 阅读全文
posted @ 2014-07-27 04:36 爱做饭的小莹子 阅读(6211) 评论(1) 推荐(0) 编辑
摘要:题目:Implement pow(x, n).题解:pow(x,n)就是求x的n次方。x的N次方可以看做:x^n = x^(n/2)*x^(n/2)*x^(n%2)。所以利用递归求解,当n==1的时候,x^n=x。当然n是可以小于0的,2^(-3) = 1/(2^3)。按照上面那个规律就可以解决了... 阅读全文
posted @ 2014-07-27 03:03 爱做饭的小莹子 阅读(6035) 评论(0) 推荐(0) 编辑
摘要:题目:Given an array of integers, every element appears three times except for one. Find that single one.Note:Your algorithm should have a linear runtim... 阅读全文
posted @ 2014-07-27 00:57 爱做饭的小莹子 阅读(3437) 评论(0) 推荐(0) 编辑
摘要:题目:Given an array of integers, every element appears twice except for one. Find that single one.Note:Your algorithm should have a linear runtime comp... 阅读全文
posted @ 2014-07-26 23:47 爱做饭的小莹子 阅读(2812) 评论(0) 推荐(0) 编辑
摘要:题目:Given an unsorted array of integers, find the length of the longest consecutive elements sequence.For example,Given [100, 4, 200, 1, 3, 2],The lon... 阅读全文
posted @ 2014-07-26 13:07 爱做饭的小莹子 阅读(2487) 评论(0) 推荐(0) 编辑
摘要:题目:Given a 2D board containing 'X' and 'O', capture all regions surrounded by 'X'.A region is captured by flipping all 'O's into 'X's in that surroun... 阅读全文
posted @ 2014-07-26 11:59 爱做饭的小莹子 阅读(3596) 评论(0) 推荐(0) 编辑
摘要:题目:Evaluate the value of an arithmetic expression in Reverse Polish Notation.Valid operators are +, -, *, /. Each operand may be an integer or anothe... 阅读全文
posted @ 2014-07-26 10:31 爱做饭的小莹子 阅读(1237) 评论(0) 推荐(1) 编辑
摘要:String 字符串常量StringBuffer 字符串变量(线程安全)StringBuilder 字符串变量(非线程安全)简要的说, String 类型和 StringBuffer 类型的主要性能区别其实在于 String 是不可变的对象, 因此在每次对 String 类型进行改变的时候其实都等同... 阅读全文
posted @ 2014-07-26 10:19 爱做饭的小莹子 阅读(661) 评论(0) 推荐(1) 编辑
摘要:题目:Given an absolute path for a file (Unix-style), simplify it.For example,path = "/home/", => "/home"path = "/a/./b/../../c/", => "/c"Corner Cases:D... 阅读全文
posted @ 2014-07-26 10:09 爱做饭的小莹子 阅读(5659) 评论(1) 推荐(1) 编辑
摘要:题目:Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring.For "(()", the... 阅读全文
posted @ 2014-07-26 05:28 爱做饭的小莹子 阅读(3174) 评论(0) 推荐(0) 编辑
摘要:题目:Given a 2D binary matrix filled with 0's and 1's, find the largest rectangle containing all ones and return its area.题解:这道题可以应用之前解过的Largetst Recta... 阅读全文
posted @ 2014-07-26 05:08 爱做饭的小莹子 阅读(2553) 评论(0) 推荐(0) 编辑
摘要:题目:Given n non-negative integers representing the histogram's bar height where the width of each bar is 1, find the area of largest rectangle in the ... 阅读全文
posted @ 2014-07-26 04:13 爱做饭的小莹子 阅读(2227) 评论(0) 推荐(0) 编辑
摘要:题目:Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.The brackets must close in t... 阅读全文
posted @ 2014-07-26 03:51 爱做饭的小莹子 阅读(5737) 评论(0) 推荐(0) 编辑
摘要:题目:Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: get and set.get(key) - Get ... 阅读全文
posted @ 2014-07-26 03:18 爱做饭的小莹子 阅读(9563) 评论(1) 推荐(2) 编辑
摘要:题目:Sort a linked list in O(n log n) time using constant space complexity.题解:考虑到要求用O(nlogn)的时间复杂度和constant space complexity来sort list,自然而然想到了merge sor... 阅读全文
posted @ 2014-07-26 02:51 爱做饭的小莹子 阅读(4476) 评论(0) 推荐(1) 编辑
摘要:题目:Given a singly linked list L: L0→L1→…→Ln-1→Ln,reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→…You must do this in-place without altering the nodes' values.F... 阅读全文
posted @ 2014-07-26 02:21 爱做饭的小莹子 阅读(2003) 评论(0) 推荐(0) 编辑
摘要:leetcode很多题目都是利用快慢指针来解决题目,下面具体讲解下快慢指针。概念: 快指针在每一步走的步长要比慢指针一步走的步长要多。快指针通常的步速是慢指针的2倍。在循环中的指针移动通常为:faster = faster.next.next, slower = slower.next.应用:1.... 阅读全文
posted @ 2014-07-26 02:05 爱做饭的小莹子 阅读(1229) 评论(0) 推荐(0) 编辑
摘要:题目:Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.题解:Merge k sorted linked list就是merge 2 sorted li... 阅读全文
posted @ 2014-07-26 00:12 爱做饭的小莹子 阅读(4321) 评论(0) 推荐(1) 编辑
摘要:题目:Given a linked list, reverse the nodes of a linked list k at a time and return its modified list.If the number of nodes is not a multiple of k the... 阅读全文
posted @ 2014-07-24 04:31 爱做饭的小莹子 阅读(2920) 评论(0) 推荐(0) 编辑
摘要:题目:You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a sin... 阅读全文
posted @ 2014-07-24 03:58 爱做饭的小莹子 阅读(5904) 评论(0) 推荐(0) 编辑
摘要:题目:A linked list is given such that each node contains an additional random pointer which could point to any node in the list or null.Return a deep c... 阅读全文
posted @ 2014-07-24 02:46 爱做饭的小莹子 阅读(4851) 评论(0) 推荐(0) 编辑
摘要:题目:Given a list, rotate the list to the right by k places, where k is non-negative.For example:Given 1->2->3->4->5->NULL and k = 2,return 4->5->1->2-... 阅读全文
posted @ 2014-07-24 00:54 爱做饭的小莹子 阅读(4807) 评论(0) 推荐(0) 编辑
摘要:题目:Given a binary tree, flatten it to a linked list in-place.For example,Given 1 / \ 2 5 / \ \ 3 4 6The flatten... 阅读全文
posted @ 2014-07-24 00:08 爱做饭的小莹子 阅读(4815) 评论(0) 推荐(0) 编辑
摘要:题目:Reverse a linked list from position m to n. Do it in-place and in one-pass.For example:Given 1->2->3->4->5->NULL, m = 2 and n = 4,return 1->4->3->... 阅读全文
posted @ 2014-07-23 23:37 爱做饭的小莹子 阅读(2830) 评论(0) 推荐(1) 编辑
摘要:题目:Sort a linked list using insertion sort.题解:Insertion Sort就是把一个一个元素往已排好序的list中插入的过程。初始时,sorted list是空,把一个元素插入sorted list中。然后,在每一次插入过程中,都是找到最合适位置进行插... 阅读全文
posted @ 2014-07-23 10:45 爱做饭的小莹子 阅读(4564) 评论(1) 推荐(0) 编辑
摘要:题目: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 preserve t... 阅读全文
posted @ 2014-07-23 10:21 爱做饭的小莹子 阅读(4115) 评论(0) 推荐(1) 编辑
摘要:题目:Given a linked list, remove the nth node from the end of list and return its head.For example, Given linked list: 1->2->3->4->5, and n = 2. Af... 阅读全文
posted @ 2014-07-23 09:16 爱做饭的小莹子 阅读(4620) 评论(0) 推荐(0) 编辑
摘要:题目:Given a linked list, return the node where the cycle begins. If there is no cycle, return null.Follow up:Can you solve it without using extra spac... 阅读全文
posted @ 2014-07-23 05:32 爱做饭的小莹子 阅读(3259) 评论(0) 推荐(0) 编辑
摘要:题目:Given a linked list, determine if it has a cycle in it.Follow up:Can you solve it without using extra space?题解:这道题连带着II是很经典的,在看CC150时候,纠结这个问题纠结了很久... 阅读全文
posted @ 2014-07-23 05:03 爱做饭的小莹子 阅读(2120) 评论(0) 推荐(0) 编辑
摘要:题目:Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list.For example,Given 1... 阅读全文
posted @ 2014-07-23 04:32 爱做饭的小莹子 阅读(2980) 评论(0) 推荐(0) 编辑
摘要:题目:Given a sorted linked list, delete all duplicates such that each element appear only once.For example,Given 1->1->2, return 1->2.Given 1->1->2->3-... 阅读全文
posted @ 2014-07-23 03:56 爱做饭的小莹子 阅读(1709) 评论(0) 推荐(0) 编辑
摘要:题目: Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists. 题解:... 阅读全文
posted @ 2014-07-23 03:24 爱做饭的小莹子 阅读(3425) 评论(0) 推荐(0) 编辑
摘要:题目:Given a linked list, swap every two adjacent nodes and return its head.For example,Given 1->2->3->4, you should return the list as 2->1->4->3.http... 阅读全文
posted @ 2014-07-23 03:01 爱做饭的小莹子 阅读(5798) 评论(0) 推荐(0) 编辑
摘要:题目:There are two sorted arrays A and B of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should ... 阅读全文
posted @ 2014-07-23 00:45 爱做饭的小莹子 阅读(9897) 评论(1) 推荐(1) 编辑
摘要:题目: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 integ... 阅读全文
posted @ 2014-07-22 11:35 爱做饭的小莹子 阅读(3892) 评论(1) 推荐(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 @ 2014-07-22 11:05 爱做饭的小莹子 阅读(3401) 评论(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 @ 2014-07-22 05:13 爱做饭的小莹子 阅读(6701) 评论(3) 推荐(1) 编辑
摘要:Hashtable:1. key和value都不许有null值2. 使用enumeration遍历3. 同步的,每次只有一个线程能够访问4. 在java中Hashtable是H大写,t小写,而HashMap是H大写,M大写HashMap:1. key和value可以有null值2. 使用itera... 阅读全文
posted @ 2014-07-22 04:10 爱做饭的小莹子 阅读(2207) 评论(0) 推荐(1) 编辑
摘要:题目:Given an array of integers, find two numbers such that they add up to a specific target number.The function twoSum should return indices of the tw... 阅读全文
posted @ 2014-07-22 03:44 爱做饭的小莹子 阅读(6872) 评论(3) 推荐(2) 编辑
摘要:题目:Follow up for "Search in Rotated Sorted Array":What if duplicates are allowed?Would this affect the run-time complexity? How and why?Write a funct... 阅读全文
posted @ 2014-07-22 00:40 爱做饭的小莹子 阅读(3301) 评论(0) 推荐(0) 编辑
摘要:题目:Suppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).You are given a target ... 阅读全文
posted @ 2014-07-21 11:55 爱做饭的小莹子 阅读(3408) 评论(1) 推荐(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 sorte... 阅读全文
posted @ 2014-07-21 10:44 爱做饭的小莹子 阅读(4275) 评论(1) 推荐(0) 编辑
摘要:Reference: http://blog.csdn.net/lbyxiafei/article/details/9375735题目:Implement int sqrt(int x).Compute and return the square root of x.题解: 这道题很巧妙的运用了二... 阅读全文
posted @ 2014-07-21 09:34 爱做饭的小莹子 阅读(4249) 评论(2) 推荐(1) 编辑
摘要:题目: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 @ 2014-07-21 08:31 爱做饭的小莹子 阅读(4075) 评论(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 or... 阅读全文
posted @ 2014-07-21 04:20 爱做饭的小莹子 阅读(2149) 评论(0) 推荐(1) 编辑
摘要:二分查找方法二分查找经常用来在有序的数列查找某个特定的位置。因此,应用二分查找法,这个数列必须包含以下特征:存储在数组中有序排列二分查找方法不适用于链表,因为链表方法需要遍历,应用二分查找法意义不大。一般情况下,我们默认数组是单调递增数列,且无重复元素。(有重复元素的题应该如何解决)二分查找方法递归... 阅读全文
posted @ 2014-07-21 03:53 爱做饭的小莹子 阅读(1160) 评论(0) 推荐(0) 编辑

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