- 博客(21)
- 收藏
- 关注
原创 LeetCode 287. Find the Duplicate Number
问题描述:Given an array nums containing n + 1 integers where each integer is between 1 and n (inclusive), prove that at least one duplicate number must exist. Assume that there is only one duplicate
2017-06-15 17:27:46
196
原创 LeetCode 378. Kth Smallest Element in a Sorted Matrix
问题描述:Given a n x n matrix where each of the rows and columns are sorted in ascending order, find the kth smallest element in the matrix.Note that it is the kth smallest element in the sorted
2017-06-15 16:16:39
314
原创 算法概论 8,16
问题描述:思路:问题的核心在于如何把3sat问题规约到烹调实验问题,若成功规约,那么易得:如果烹调实验问题能够在多项式时间内解决,则3sat也可以。证明:假设我们现在面对的是n个variable(以下简称V),m个clausees(以下简称C)的3SAT问题,那么我们构建一个(2n+3m)*(2n+3m)的和谐度矩阵:每个variable都可以产生两种配料:
2017-06-14 19:26:23
313
原创 LeetCode 401. Binary Watch
题目描述:A binary watch has 4 LEDs on the top which represent the hours (0-11), and the 6 LEDs on the bottom represent the minutes (0-59).Each LED represents a zero or one, with the least signif
2017-06-14 12:25:25
261
原创 LeetCode 504. Base 7
问题描述:Given an integer, return its base 7 string representation.Example 1:Input: 100Output: "202"Example 2:Input: -7Output: "-10"Note: The input will be in range o
2017-06-13 17:10:49
246
原创 LeetCode 405. Convert a Number to Hexadecimal
问题描述:Given an integer, write an algorithm to convert it to hexadecimal. For negative integer, two’s complement method is used.Note:All letters in hexadecimal (a-f) must be in lowercase
2017-05-26 18:42:57
176
原创 LeetCode 415. Add Strings
问题描述:Given two non-negative integers num1 and num2 represented as string, return the sum of num1 and num2.Note:The length of both num1 and num2 is Both num1 and num2 contains only
2017-05-26 17:04:15
252
原创 LeerCode 394. Decode String
问题描述:Given an encoded string, return it's decoded string.The encoding rule is: k[encoded_string], where the encoded_string inside the square brackets is being repeated exactly k times. Not
2017-05-26 12:59:47
247
原创 LeetCode 435. Non-overlapping Intervals
问题描述:Given a collection of intervals, find the minimum number of intervals you need to remove to make the rest of the intervals non-overlapping.Note:You may assume the interval's end p
2017-05-25 18:37:04
291
原创 LeetCode 62. Unique Paths
问题描述:A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below).The robot can only move either down or right at any point in time. The robot is trying to
2017-05-25 17:17:38
194
原创 LeetCode 167. Two Sum II - Input array is sorted
问题描述:Given an array of integers that is already sorted in ascending order, find two numbers such that they add up to a specific target number.The function twoSum should return indices of the two
2017-05-03 16:33:38
142
原创 LeetCode 347. Top K Frequent Elements
问题描述:Given a non-empty array of integers, return the k most frequent elements.For example,Given [1,1,1,2,2,3] and k = 2, return [1,2].Note: You may assume k is always valid, 1 ≤ k ≤ nu
2017-05-03 14:57:30
156
原创 LeetCode 503. Next Greater Element II
问题描述:Given a circular array (the next element of the last element is the first element of the array), print the Next Greater Number for every element. The Next Greater Number of a number x is the fi
2017-05-03 12:38:46
218
原创 LeetCode 506. Relative Ranks
问题描述:Given scores of N athletes, find their relative ranks and the people with the top three highest scores, who will be awarded medals: "Gold Medal", "Silver Medal" and "Bronze Medal".Example 1
2017-04-27 20:30:33
168
原创 LeetCode 240. Search a 2D Matrix II
问题描述: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 in ascending from left to right.I
2017-04-09 21:40:42
263
原创 LeetCode 83. Remove Duplicates from Sorted List
这次比较简单是用C++写的题目描述: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 for another array, you
2017-04-09 21:14:24
148
原创 LeetCode 451. Sort Characters By Frequency
问题描述:Given a string, sort it in decreasing order based on the frequency of characters.Example 1:Input:"tree"Output:"eert"Explanation:'e' appears twice while 'r' and 't' both appear
2017-03-26 22:09:14
344
原创 LeetCode 260. Single Number III
依然还是用熟悉的python写的问题描述:Given an array of numbers nums, in which exactly two elements appear only once and all the other elements appear exactly twice. Find the two elements that appear only once
2017-03-19 20:20:29
185
原创 LeetCode 268 MissingNumber 复杂度限制
本来想用C++写的,但是写的过程中发现很多语法都记不清了,索性转回Python,c++以后再练吧问题描述:Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one that is missing from the array.For example,Given nums
2017-03-10 09:49:07
179
原创 LeetCode 53 分治算法,求最大子串
本来想用C++写的,但是写的过程中发现很多语法都记不清了,索性转回python,c++以后再练吧问题描述:Find the contiguous subarray within an array (containing at least one number) which has the largest sum.For example, given the array [-2,1,
2017-03-06 19:05:38
959
原创 LeetCode 70 斐波那契数列
问题描述:You are climbing a stair case. It takes n steps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?Note: Given n will
2017-03-05 21:29:15
1206
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人