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,
阅读全文
摘要: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
阅读全文
摘要:题目: 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
阅读全文
摘要:题目: 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
阅读全文
摘要:题目: 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
阅读全文
摘要: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
阅读全文
摘要:DescriptionGiven a target number and an integer array sorted in ascending order. Find the total number of occurrences of target in the array.ExampleGi
阅读全文
摘要:题目: 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
阅读全文
摘要:题目: 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
阅读全文
摘要: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
阅读全文
摘要: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] >
阅读全文
摘要: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
阅读全文
摘要:题目: 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
阅读全文
摘要:题目: 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
阅读全文
摘要:题目: 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
阅读全文
摘要:题目: 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
阅读全文
摘要:题目: 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
阅读全文
摘要:题目: 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
阅读全文
摘要:题目: 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
阅读全文
摘要:题目: Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; } Populate each next pointer to point to it
阅读全文
摘要:题目: 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
阅读全文
摘要:题目: Given a set of distinct integers, nums, return all possible subsets. Note: The solution set must not contain duplicate subsets. For example,If num
阅读全文
摘要: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
阅读全文
摘要:4/23/2017 算法班 注意返回的是值,而不是index
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要:题目: Given a collection of integers that might contain duplicates, nums, return all possible subsets. Note: The solution set must not contain duplicate
阅读全文
摘要:题目: Implement strStr(). Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack. 链接:https://leetcode.
阅读全文
摘要:题目: 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
阅读全文
摘要:题目: 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
阅读全文
摘要:题目: Given an array of strings, group anagrams together. For example, given: ["eat", "tea", "tan", "ate", "nat", "bat"], Return: Note: All inputs will
阅读全文
摘要:题目: Implement pow(x, n). 链接: http://leetcode.com/problems/powx-n/ 题解: 使用二分法求实数幂,假如不建立临时变量halfPow,直接return计算结果的话会超时,还没仔细研究为什么。 4/15/2017 22ms, 50% 要考虑到
阅读全文
摘要:题目: 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
阅读全文
摘要:题目: Given a collection of numbers that might contain duplicates, return all possible unique permutations. For example,[1,1,2] have the following uniqu
阅读全文
摘要:题目: 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
阅读全文
摘要:题目: Given two numbers represented as strings, return multiplication of the numbers as a string. Note: The numbers can be arbitrarily large and are non
阅读全文
摘要:题目: 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
阅读全文
摘要:题目: 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
阅读全文
摘要:题目: Determine if a Sudoku is valid, according to: Sudoku Puzzles - The Rules. The Sudoku board could be partially filled, where empty cells are filled
阅读全文
摘要:题目: 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
阅读全文
摘要:题目: 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
阅读全文
摘要:题目: Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers. If such arrangement is not po
阅读全文
摘要:题目: Divide two integers without using multiplication, division and mod operator. If it is overflow, return MAX_INT. 链接:https://leetcode.com/problems/d
阅读全文
摘要:题目: 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
阅读全文
摘要:题目: 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
阅读全文
摘要:题目: 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
阅读全文
摘要:题目: 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
阅读全文
摘要:题目: 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
阅读全文
摘要:题目: 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
阅读全文
摘要:题目: 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
阅读全文
摘要:题目: 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
阅读全文
摘要:题目: 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
阅读全文
摘要:题目: 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
阅读全文
摘要:题目: 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
阅读全文
摘要:题目: Given a string, find the length of the longest substring without repeating characters. Examples: Given "abcabcbb", the answer is "abc", which the
阅读全文
摘要:题目: 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
阅读全文
摘要:题目: 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
阅读全文
摘要:题目 : 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
阅读全文
摘要:题目: 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
阅读全文
摘要:题目: Given a binary search tree with non-negative values, find the minimum absolute difference between values of any two nodes. Example: Note: There ar
阅读全文
摘要:题目: 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
阅读全文
摘要:题目: 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
阅读全文
浙公网安备 33010602011771号