04 2017 档案

摘要:DescriptionFind any position of a target number in a sorted array. Return -1 if target does not exist. ExampleGiven [1, 2, 2, 4, 5, 5].For target = 2, 阅读全文
posted @ 2017-04-28 05:02 panini 阅读(567) 评论(0) 推荐(0)
摘要:DescriptionWrite an efficient algorithm that searches for a value in an m x n matrix, return the occurrence of it.This matrix has the following proper 阅读全文
posted @ 2017-04-28 02:47 panini 阅读(215) 评论(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 sort 阅读全文
posted @ 2017-04-28 02:46 panini 阅读(198) 评论(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 s 阅读全文
posted @ 2017-04-27 10:15 panini 阅读(135) 评论(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 @ 2017-04-27 09:57 panini 阅读(186) 评论(0) 推荐(0)
摘要:DescriptionFor a given sorted array (ascending order) and a target number, find the first index of this number in O(log n) time complexity.If the targ 阅读全文
posted @ 2017-04-26 20:21 panini 阅读(273) 评论(0) 推荐(0)
摘要:DescriptionGiven a target number and an integer array sorted in ascending order. Find the total number of occurrences of target in the array.ExampleGi 阅读全文
posted @ 2017-04-26 20:20 panini 阅读(521) 评论(0) 推荐(0)
摘要:题目: An image is represented by a binary matrix with 0 as a white pixel and 1 as a black pixel. The black pixels are connected, i.e., there is only one 阅读全文
posted @ 2017-04-26 11:00 panini 阅读(199) 评论(0) 推荐(0)
摘要:题目: The set [1,2,3,…,n] contains a total of n! unique permutations. By listing and labeling all of the permutations in order,We get the following sequ 阅读全文
posted @ 2017-04-26 06:14 panini 阅读(199) 评论(0) 推荐(0)
摘要:DescriptionThe code base version is an integer start from 1 to n. One day, someone committed a bad version in the code case, so it caused this version 阅读全文
posted @ 2017-04-25 11:02 panini 阅读(219) 评论(0) 推荐(0)
摘要:DescriptionThere is an integer array which has the following features:The numbers in adjacent positions are different.A[0] < A[1] && A[A.length - 2] > 阅读全文
posted @ 2017-04-25 10:57 panini 阅读(200) 评论(0) 推荐(0)
摘要:DescriptionSuppose 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).Find the minimum 阅读全文
posted @ 2017-04-25 10:38 panini 阅读(167) 评论(0) 推荐(0)
摘要:题目: You are given two non-empty linked lists representing two non-negative integers. The most significant digit comes first and each of their nodes co 阅读全文
posted @ 2017-04-25 10:04 panini 阅读(171) 评论(0) 推荐(0)
摘要:题目: Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000. Example: Example: 链接:https://l 阅读全文
posted @ 2017-04-25 10:04 panini 阅读(129) 评论(0) 推荐(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]. 链接:htt 阅读全文
posted @ 2017-04-25 10:03 panini 阅读(178) 评论(0) 推荐(0)
摘要:题目: Given an integer n, return 1 - n in lexicographical order. For example, given 13, return: [1,10,11,12,13,2,3,4,5,6,7,8,9]. Please optimize your al 阅读全文
posted @ 2017-04-25 10:03 panini 阅读(168) 评论(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 @ 2017-04-25 10:03 panini 阅读(119) 评论(0) 推荐(0)
摘要:题目: A robot is located at the top-left corner of a m x ngrid (marked 'Start' in the diagram below). The robot can only move either down or right at an 阅读全文
posted @ 2017-04-25 10:03 panini 阅读(129) 评论(0) 推荐(0)
摘要:题目: Follow up for problem "Populating Next Right Pointers in Each Node". What if the given tree could be any binary tree? Would your previous solution 阅读全文
posted @ 2017-04-25 10:03 panini 阅读(143) 评论(0) 推荐(0)
摘要:题目: Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; } Populate each next pointer to point to it 阅读全文
posted @ 2017-04-25 10:03 panini 阅读(103) 评论(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 阅读全文
posted @ 2017-04-25 10:03 panini 阅读(460) 评论(0) 推荐(0)
摘要:题目: Given a set of distinct integers, nums, return all possible subsets. Note: The solution set must not contain duplicate subsets. For example,If num 阅读全文
posted @ 2017-04-25 10:02 panini 阅读(304) 评论(0) 推荐(0)
该文被密码保护。
posted @ 2017-04-25 10:01 panini 阅读(3) 评论(0) 推荐(0)
摘要:DescriptionGiven a big sorted array with positive integers sorted by ascending order. The array is so big so that you can not get the length of the wh 阅读全文
posted @ 2017-04-24 08:50 panini 阅读(472) 评论(1) 推荐(0)
摘要:4/23/2017 算法班 注意返回的是值,而不是index 阅读全文
posted @ 2017-04-24 08:40 panini 阅读(470) 评论(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 f 阅读全文
posted @ 2017-04-24 08:27 panini 阅读(184) 评论(0) 推荐(0)
摘要:DescriptionGiven a target number and an integer array A sorted in ascending order, find the index i in A such that A[i] is closest to the given target 阅读全文
posted @ 2017-04-24 08:11 panini 阅读(545) 评论(0) 推荐(0)
摘要:题目: Given a collection of integers that might contain duplicates, nums, return all possible subsets. Note: The solution set must not contain duplicate 阅读全文
posted @ 2017-04-23 07:25 panini 阅读(177) 评论(0) 推荐(0)
摘要:题目: Implement strStr(). Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack. 链接:https://leetcode. 阅读全文
posted @ 2017-04-23 02:55 panini 阅读(177) 评论(0) 推荐(0)
该文被密码保护。
posted @ 2017-04-21 00:00 panini 阅读(5) 评论(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 m 阅读全文
posted @ 2017-04-20 05:59 panini 阅读(159) 评论(0) 推荐(0)
摘要:题目: Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order. For example,Given the following matrix: Y 阅读全文
posted @ 2017-04-20 01:01 panini 阅读(195) 评论(0) 推荐(0)
摘要:题目: Given an array of strings, group anagrams together. For example, given: ["eat", "tea", "tan", "ate", "nat", "bat"], Return: Note: All inputs will 阅读全文
posted @ 2017-04-19 23:56 panini 阅读(171) 评论(0) 推荐(0)
摘要:题目: Implement pow(x, n). 链接: http://leetcode.com/problems/powx-n/ 题解: 使用二分法求实数幂,假如不建立临时变量halfPow,直接return计算结果的话会超时,还没仔细研究为什么。 4/15/2017 22ms, 50% 要考虑到 阅读全文
posted @ 2017-04-16 11:22 panini 阅读(165) 评论(0) 推荐(0)
摘要:题目: You are given an n x n 2D matrix representing an image. Rotate the image by 90 degrees (clockwise). Follow up:Could you do this in-place? 链接: http 阅读全文
posted @ 2017-04-16 10:16 panini 阅读(108) 评论(0) 推荐(0)
摘要:题目: Given a collection of numbers that might contain duplicates, return all possible unique permutations. For example,[1,1,2] have the following uniqu 阅读全文
posted @ 2017-04-16 07:57 panini 阅读(187) 评论(0) 推荐(0)
摘要:题目: Given a collection of numbers, return all possible permutations. For example,[1,2,3] have the following permutations:[1,2,3], [1,3,2], [2,1,3], [2 阅读全文
posted @ 2017-04-16 06:27 panini 阅读(245) 评论(0) 推荐(0)
摘要:题目: Given two numbers represented as strings, return multiplication of the numbers as a string. Note: The numbers can be arbitrarily large and are non 阅读全文
posted @ 2017-04-16 03:02 panini 阅读(175) 评论(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 @ 2017-04-15 10:38 panini 阅读(144) 评论(0) 推荐(0)
摘要:题目: Given a set of candidate numbers (C) (without duplicates) and a target number (T), find all unique combinations in C where the candidate numbers s 阅读全文
posted @ 2017-04-15 10:15 panini 阅读(372) 评论(0) 推荐(0)
摘要:题目: Determine if a Sudoku is valid, according to: Sudoku Puzzles - The Rules. The Sudoku board could be partially filled, where empty cells are filled 阅读全文
posted @ 2017-04-15 08:01 panini 阅读(155) 评论(0) 推荐(0)
摘要:题目: Given an array of integers sorted in ascending order, find the starting and ending position of a given target value. Your algorithm's runtime comp 阅读全文
posted @ 2017-04-15 05:44 panini 阅读(172) 评论(0) 推荐(0)
摘要:题目: Suppose an array sorted in ascending order 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). Y 阅读全文
posted @ 2017-04-15 03:55 panini 阅读(121) 评论(0) 推荐(0)
摘要:题目: Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers. If such arrangement is not po 阅读全文
posted @ 2017-04-15 00:47 panini 阅读(225) 评论(0) 推荐(0)
摘要:题目: Divide two integers without using multiplication, division and mod operator. If it is overflow, return MAX_INT. 链接:https://leetcode.com/problems/d 阅读全文
posted @ 2017-04-14 01:51 panini 阅读(225) 评论(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. Yo 阅读全文
posted @ 2017-04-13 01:33 panini 阅读(144) 评论(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 i 阅读全文
posted @ 2017-04-12 23:46 panini 阅读(181) 评论(0) 推荐(0)
摘要:题目: Given a linked list, remove the nth node from the end of list and return its head. For example, Note:Given n will always be valid.Try to do this i 阅读全文
posted @ 2017-04-12 10:57 panini 阅读(146) 评论(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 阅读全文
posted @ 2017-04-12 02:32 panini 阅读(150) 评论(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 tel 阅读全文
posted @ 2017-04-11 19:56 panini 阅读(183) 评论(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 integ 阅读全文
posted @ 2017-04-10 08:40 panini 阅读(129) 评论(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 @ 2017-04-10 07:59 panini 阅读(131) 评论(0) 推荐(0)
摘要:题目: Given an integer, convert it to a roman numeral. Input is guaranteed to be within the range from 1 to 3999. 链接:https://leetcode.com/problems/integ 阅读全文
posted @ 2017-04-10 04:34 panini 阅读(106) 评论(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 @ 2017-04-10 03:49 panini 阅读(133) 评论(0) 推荐(0)
摘要:题目: Implement atoi to convert a string to an integer. Hint: Carefully consider all possible input cases. If you want a challenge, please do not see be 阅读全文
posted @ 2017-04-10 02:03 panini 阅读(167) 评论(0) 推荐(0)
摘要:题目: The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed f 阅读全文
posted @ 2017-04-05 05:39 panini 阅读(132) 评论(0) 推荐(0)
摘要:题目: Given a string, find the length of the longest substring without repeating characters. Examples: Given "abcabcbb", the answer is "abc", which the 阅读全文
posted @ 2017-04-04 03:49 panini 阅读(135) 评论(0) 推荐(0)
摘要:题目: You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes co 阅读全文
posted @ 2017-04-04 02:32 panini 阅读(194) 评论(0) 推荐(0)
摘要:题目: Given a binary tree, you need to compute the length of the diameter of the tree. The diameter of a binary tree is the length of the longest path b 阅读全文
posted @ 2017-04-01 23:42 panini 阅读(170) 评论(0) 推荐(0)
摘要:题目 : Given a string and an integer k, you need to reverse the first k characters for every 2k characters counting from the start of the string. If the 阅读全文
posted @ 2017-04-01 23:30 panini 阅读(406) 评论(0) 推荐(0)
摘要:题目: Given an array of integers and an integer k, you need to find the number of unique k-diff pairs in the array. Here a k-diff pair is defined as an 阅读全文
posted @ 2017-04-01 05:29 panini 阅读(142) 评论(0) 推荐(0)
摘要:题目: Given a binary search tree with non-negative values, find the minimum absolute difference between values of any two nodes. Example: Note: There ar 阅读全文
posted @ 2017-04-01 04:41 panini 阅读(198) 评论(0) 推荐(0)
摘要:题目: Given a word, you need to judge whether the usage of capitals in it is right or not. We define the usage of capitals in a word to be right when on 阅读全文
posted @ 2017-04-01 03:02 panini 阅读(208) 评论(0) 推荐(0)
摘要:题目: We define the Perfect Number is a positive integer that is equal to the sum of all its positive divisors except itself. Now, given an integer n, w 阅读全文
posted @ 2017-04-01 02:30 panini 阅读(331) 评论(0) 推荐(0)