自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(50)
  • 收藏
  • 关注

原创 260. Single Number III

问题描述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.For example:Given nums =

2018-04-29 09:24:10 99

原创 19. Remove Nth Node From End of List

问题描述Given a linked list, remove the n-th node from the end of list and return its head.Example: Given linked list: 1->2->3->4->5, and n = 2. After removing the second node from the end, the link

2018-04-29 08:30:34 111

原创 79. Word Search

问题描述Given a 2D board and a word, find if the word exists in the grid.The word can be constructed from letters of sequentially adjacent cell, where “adjacent” cells are those horizontally or vertically

2018-04-29 07:27:48 113

原创 89. Gray Code

问题描述The gray code is a binary numeral system where two successive values differ in only one bit.Given a non-negative integer n representing the total number of bits in the code, print the sequence of g

2018-04-29 06:28:25 121

原创 73. Set Matrix Zeroes

问题描述Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in-place.Example 1: I**nput:** [ [1,1,1], [1,0,1], [1,1,1] ] Output: [ [1,0,1

2018-04-29 06:04:35 114

原创 279. Perfect Squares

问题描述Given a positive integer n, find the least number of perfect square numbers (for example, 1, 4, 9, 16, ...) which sum to n.For example, given n = 12, return 3 because 12 = 4 + 4 + 4; given n = 13,

2018-04-29 02:02:40 113

原创 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 number,

2018-04-28 14:37:26 129

原创 43. Multiply Strings

问题描述Given two non-negative integers num1 and num2 represented as strings, return the product of num1 and num2, also represented as a string.Example 1: Input: num1 = “2”, num2 = “3” Output: “6”Exa

2018-04-28 13:52:32 108

原创 24. Swap Nodes in Pairs(递归)

问题描述Given a linked list, swap every two adjacent nodes and return its head.Example: Given 1->2->3->4, you should return the list as 2->1->4->3.Note:Your algorithm should use only constant extra spa

2018-04-26 02:51:22 273

原创 142. Linked List Cycle II

问题描述Given a linked list, return the node where the cycle begins. If there is no cycle, return null.Note: Do not modify the linked list.Follow up: Can you solve it without using extra space?题目链接:思路分析给一

2018-04-25 15:45:33 149

原创 229. Majority Element II

问题描述Given an integer array of size n, find all elements that appear more than ⌊ n/3 ⌋ times. The algorithm should run in linear time and in O(1) space.题目链接:思路分析给一个数组,返回数组中出现次数超过⌊n/3⌋⌊ n / 3 ⌋次的元素。要求线性时

2018-04-25 14:49:01 130

转载 CuckooHash(布谷鸟散列)

概念CuckooHash(布谷鸟散列),最早于2001 年由Rasmus Pagh 和Flemming Friche Rodler 提出。是为了解决哈希冲突问题,利用较少的计算换取较大的空间。 wikipedia - Cuckoo hashing 特点:占用空间少,查询速度快。 来源:之所以起这个名字是因为布谷鸟生性贪婪,不自己筑巢,而是在别的鸟巢里面鸟蛋孵化,先成长的幼鸟会将别的鸟蛋挤出,这

2018-04-23 07:47:04 10154 3

转载 队列

队列的定义**队列:**queue,是先进先出(FIFO, First-In-First-Out)的线性表。在具体应用中通常用链表或者数组来实现。队列只允许在后端(称为rear)进行插入操作,在前端(称为front)进行删除操作。队列的操作方式和堆栈类似,唯一的区别在于队列只允许新数据在后端进行添加。 维基-队列队列的基本特点:先入先出,后入后出。除头尾节点之外,每个元素有一个前驱,一个后继。

2018-04-23 05:39:12 295

原创 220. Contains Duplicate III

问题描述Given an array of integers, find out whether there are two distinct indices i and j in the array such that the absolute difference between nums[i] and nums[j] is at most t and the absolute differen

2018-04-23 03:53:15 142

原创 228. Summary Ranges

问题描述Given a sorted integer array without duplicates, return the summary of its ranges.Example 1: Input: [0,1,2,4,5,7] Output: [“0->2”,”4->5”,”7”]Example 2: Input: [0,2,3,4,6,8,9] Output: [“0

2018-04-22 07:29:47 145

原创 406. Queue Reconstruction by Height

问题描述Suppose you have a random list of people standing in a queue. Each person is described by a pair of integers (h, k), where h is the height of the person and k is the number of people in front of th

2018-04-22 06:57:24 132

原创 433. Minimum Genetic Mutation

问题描述A gene string can be represented by an 8-character long string, with choices from "A", "C", "G", "T".Suppose we need to investigate about a mutation (mutation from “start” to “end”), where ONE muta

2018-04-22 06:08:29 280

原创 540. Single Element in a Sorted Array

问题描述Given a sorted array consisting of only integers where every element appears twice except for one element which appears once. Find this single element that appears only once.Example 1: Input: [1,

2018-04-21 08:09:10 115

原创 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 ≤ number of unique

2018-04-21 07:34:20 210

原创 54. Spiral Matrix

问题描述Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order.Example 1: Input: [ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8, 9 ] ] Out...

2018-04-17 14:44:35 155

原创 179. Largest Number

问题描述Given a list of non negative integers, arrange them such that they form the largest number.For example, given [3, 30, 34, 5, 9], the largest formed number is 9534330.Note: The result may be ...

2018-04-17 13:01:51 177

原创 29. Divide Two Integers

问题描述Given two integers dividend and divisor, divide two integers without using multiplication, division and mod operator.Return the quotient after dividing dividend by divisor.Example 1: Inp...

2018-04-17 05:17:28 197

原创 384. Shuffle an Array

问题描述Shuffle a set of numbers without duplicates.Example: // Init an array with set 1, 2, and 3. int[] nums = {1,2,3}; Solution solution = new Solution(nums); // Shuffle the array [1...

2018-04-17 03:24:58 137

原创 96. Unique Binary Search Trees

问题描述Given n, how many structurally unique BST’s (binary search trees) that store values 1…n?For example, Given n = 3, there are a total of 5 unique BST’s. 题目链接:思路分析给一数n,计算n个数可以生成多少个不同的二叉...

2018-04-17 02:55:05 135

原创 16. 3Sum Closest

问题描述Given an array nums of n integers and an integer target, find three integers in nums such that the sum is closest to target. Return the sum of the three integers. You may assume that each input ...

2018-04-17 02:18:33 128

原创 173. Binary Search Tree Iterator

问题描述Implement an iterator over a binary search tree (BST). Your iterator will be initialized with the root node of a BST.Calling next() will return the next smallest number in the BST.Note: next...

2018-04-17 01:57:50 125

原创 147. Insertion Sort List

问题描述Sort a linked list using insertion sort.题目链接:思路分析用插入排序对一个链表进行排序。插入排序就是对于新的元素,将它插入到已排序的元素的合适位置。如果是在数组中,还需要移动元素,但是对于链表就没有这个必要了,所以非常适合链表。我们设置一个新的头new_head,cur = head表示之前的结点已经排序,和一个寻找合适位...

2018-04-16 14:09:32 138

原创 46. Permutations

问题描述Given a collection of distinct integers, return all possible permutations.Example: Input: [1,2,3] Output: [ [1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2], [3,2,1

2018-04-16 12:40:23 145

原创 223. Rectangle Area

问题描述Find the total area covered by two rectilinear rectangles in a 2D plane.Each rectangle is defined by its bottom left corner and top right corner as shown in the figure.Assume that the tota...

2018-04-13 15:39:49 147

原创 36. Valid Sudoku

问题描述Determine if a Sudoku is valid, according to: Sudoku Puzzles - The Rules.The Sudoku board could be partially filled, where empty cells are filled with the character '.'. A partially filled ...

2018-04-13 15:03:53 100

原创 150. Evaluate Reverse Polish Notation

问题描述Evaluate the value of an arithmetic expression in Reverse Polish Notation.Valid operators are +, -, *, /. Each operand may be an integer or another expression.Some examples: [“2”, “1”, “...

2018-04-11 15:15:41 175

原创 419. Battleships in a Board

问题描述Given an 2D board, count how many battleships are in it. The battleships are represented with 'X's, empty slots are represented with '.'s. You may assume the following rules: You receive a vali...

2018-04-11 10:21:53 123

原创 319. Bulb Switcher

问题描述There are n bulbs that are initially off. You first turn on all the bulbs. Then, you turn off every second bulb. On the third round, you toggle every third bulb (turning on if it’s off or turnin...

2018-04-11 09:57:10 130

原创 33. Search in Rotated Sorted Array

问题描述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).You are given a target value to search. If foun...

2018-04-11 03:01:33 123

原创 153. Find Minimum in Rotated Sorted Array

问题描述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).Find the minimum element.You may assume no du...

2018-04-11 02:34:52 123

原创 48. Rotate Image

问题描述You are given an n x n 2D matrix representing an image.Rotate the image by 90 degrees (clockwise).Note: You have to rotate the image in-place, which means you have to modify the input 2D ma...

2018-04-10 14:01:59 131

转载

栈的定义栈:限定在表尾进行插入和删除操作的线性表。类似于弹夹。允许插入和删除的一端为栈顶(top),另一端为栈底(bottom)。栈又称为后进先出LIFO(Last In First Out)的线性表。另外栈也可以用一维数组或链表的形式来完成。堆栈的另外一个相对的操作方式称为队列(FIFO)。 [维基-栈](https://zh.wikipedia.org/wiki/%E5%A0%86%E6%A0

2018-04-10 05:35:26 157

原创 328. Odd Even Linked List

问题描述Given a singly linked list, group all odd nodes together followed by the even nodes. Please note here we are talking about the node number and not the value in the nodes.You should try to do i...

2018-04-10 03:33:34 157

原创 8. String to Integer (atoi)

问题描述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 below and ask yourself what are the possible inpu...

2018-04-09 09:36:49 109

原创 152. Maximum Product Subarray

问题描述Find the contiguous subarray within an array (containing at least one number) which has the largest product.For example, given the array [2,3,-2,4], the contiguous subarray [2,3] has the larg...

2018-04-09 07:28:06 126

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除