![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
刷刷刷题
文章平均质量分 76
爱胡椒的小白兔呢
哼
展开
-
剑指offer
艾瑞巴蒂,我来刷剑指了,因为要找工作了呀~ ^_^ 紧急紧急!!!这里来记录下~1、二维数组的查找:题目:在一个二维数组中,每一行都按照从左到右递增的顺序排序,每一列都按照从上到下递增的顺序排序。请完成一个函数,输入这样的一个二维数组和一个整数,判断数组中是否含有该整数。思路:从右上角开始,比目标大的话往左走;比目标小的话,向下走。源码:public class Solution原创 2017-09-06 22:47:29 · 491 阅读 · 0 评论 -
Leetcode刷题记——29. Divide Two Integers(整数相除Divide two integers without using multiplication, division)
一、题目叙述:Divide two integers without using multiplication, division and mod operator.If it is overflow, return MAX_INT.两整数相除,不能使用乘法,除法和取模运算。二、解题思路:Medium题,不能用乘除取模,那原创 2017-03-03 18:57:20 · 298 阅读 · 0 评论 -
Leetcode刷题记——54. Spiral Matrix(螺旋矩阵)
一、题目叙述: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:[ [ 1, 2, 3 ], [ 4, 5, 6原创 2017-02-23 19:00:37 · 753 阅读 · 0 评论 -
Leetcode刷题记——53. Maximum Subarray(最大子串)
一、题目叙述: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,2,1,-5,4],the contiguous原创 2017-02-23 17:24:42 · 243 阅读 · 0 评论 -
Leetcode刷题记——41. First Missing Positive(第一个丢失的正数)
一、题目叙述:Given an unsorted integer array, find the first missing positive integer.For example,Given [1,2,0] return 3,and [3,4,-1,1] return 2.Your algorithm should run in O(n) tim原创 2017-02-22 21:19:27 · 322 阅读 · 0 评论 -
Leetcode刷题记——88. Merge Sorted Array(合并有序数组)
一、题目叙述:Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array.Note:You may assume that nums1 has enough space (size that is greater or equal to m + n原创 2017-02-22 20:17:52 · 272 阅读 · 0 评论 -
Leetcode刷题记——Trapping Rain Water(捕获雨水)
一、题目叙述: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 raining.For example, Given [0,1,0原创 2017-02-21 18:39:36 · 321 阅读 · 0 评论 -
Leetcode刷题记—— 84. Largest Rectangle in Histogram(柱形图中最大矩形面积)
一、题目叙述: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 histogram.Above is a histogra原创 2017-02-21 18:05:04 · 391 阅读 · 0 评论 -
Leetcode刷题记——136. Single Number(单独的数字)
一、题目叙述:Given an array of integers, every element appears twice except for one. Find that single one.Note:Your algorithm should have a linear runtime complexity. Could you imp原创 2017-02-28 16:41:58 · 239 阅读 · 0 评论 -
Leetcode刷题记——83. Remove Duplicates from Sorted List(删除有序链表的重复结点)
一、题目叙述: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->3, return 1->2->3.原创 2017-02-28 15:06:35 · 365 阅读 · 0 评论 -
Leetcode刷题记—— 35. Search Insert Position(查找插入位置)
一、题目叙述: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 o原创 2016-12-29 19:42:34 · 307 阅读 · 0 评论 -
Leetcode刷题记—— 69. Sqrt(x)(求整数x的平方根)
一、题目叙述:Implement int sqrt(int x).Compute and return the square root of x.Subscribe to see which companies asked this question即,求给定整数的平方根。原创 2016-12-29 19:19:58 · 374 阅读 · 0 评论 -
Leetcode刷题记——34. Search for a Range(查找一个范围)
一、题目叙述: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 th原创 2016-12-29 18:10:05 · 333 阅读 · 0 评论 -
Leetcode刷题记——100. Same Tree(相同的树)
一、题目叙述:Given an array of integers, every element appears twice except for one. Find that single one.Note:Your algorithm should have a linear runtime complexity. Could you imp原创 2017-03-03 19:27:51 · 283 阅读 · 0 评论 -
Leetcode刷题记——75. Sort Colors(颜色排序)
一、题目叙述: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 red, white and blue.原创 2017-03-04 17:23:58 · 436 阅读 · 0 评论 -
Leetcode刷题记—— Remove Duplicates from Sorted Array II(已排序数组移除重复元素2)
一、题目叙述:Follow up for "Remove Duplicates":What if duplicates are allowed at most twice?For example,Given sorted array nums = [1,1,1,2,2,3],Your function should retur原创 2017-03-04 17:48:51 · 353 阅读 · 0 评论 -
leetcode148套题
只刷剑指不行,宝宝我还要刷点别的,啊啊啊,实习了一天头好疼,但是不行,我要坚持坚持坚持!1、树:minimum-depth-of-binary-tree题目:Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the原创 2017-09-06 22:55:31 · 448 阅读 · 0 评论 -
Leetcode刷题记——50. Pow(x, n)
一、题目叙述:Implement pow(x, n).二、解题思路:Medium题。&参考。思路:递归实现,注意n为负时,不能用 1 / mypow(x, -n)。三、源码:public class Solution { public double m原创 2017-04-13 23:08:19 · 320 阅读 · 0 评论 -
Leetcode刷题记—— 4. Median of Two Sorted Arrays(两有序数组的中位数)
一、题目叙述:There are two sorted arrays nums1 and nums2 of size m and n respectively.Find the median of the two sorted arrays. The overall run time complexity sh原创 2017-04-12 20:02:32 · 360 阅读 · 0 评论 -
Leetcode刷题记—— 46. Permutations(排列)
一、题目叙述:Given a collection of distinct numbers, return all possible permutations.For example,[1,2,3] have the following permutations:[ [1,2,3], [1,3,2]原创 2017-03-13 20:18:22 · 235 阅读 · 0 评论 -
Leetcode刷题记——70. Climbing Stairs(爬楼梯)
一、题目叙述: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: Giv原创 2017-02-27 17:33:24 · 697 阅读 · 0 评论 -
Leetcode刷题记——48. Rotate Image(旋转图像)
一、题目叙述: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?Subscribe to see which companies原创 2017-02-26 17:18:07 · 504 阅读 · 0 评论 -
Leetcode刷题记——67. Add Binary(二进制数相加)
一、题目叙述:Given two binary strings, return their sum (also a binary string).For example,a = "11"b = "1"Return "100".Subscribe to see which companies asked this q原创 2017-02-26 16:42:51 · 322 阅读 · 0 评论 -
Leetcode刷题记—— 60. Permutation Sequence(排列序列)
一、题目叙述: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 sequence (ie原创 2017-03-05 16:48:12 · 472 阅读 · 0 评论 -
Leetcode刷题记——26. Remove Duplicates from Sorted Array(删除数组重复元素)
一、题目叙述: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原创 2016-11-01 17:47:23 · 414 阅读 · 1 评论 -
Leetcode刷题记—— 73. Set Matrix Zeroes(设置矩阵0)
一、题目叙述:Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place.click to show follow up.Subscribe to see which companies ask原创 2017-03-05 11:04:08 · 696 阅读 · 0 评论 -
Leetcode刷题记——59. Spiral Matrix II(螺旋矩阵2)
一、题目叙述:Given an integer n, generate a square matrix filled with elements from 1 to n2 in spiral order.For example,Given n = 3,You should return the following matrix:[ [原创 2017-02-25 20:02:43 · 465 阅读 · 0 评论 -
Leetcode刷题记——58. Length of Last Word(最后一个单词的长度)
一、题目叙述: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 word does not exist, r原创 2017-02-25 19:34:35 · 627 阅读 · 0 评论 -
Leetcode刷题记—— 118. Pascal's Triangle(杨辉三角形)
一、题目叙述:Given numRows, generate the first numRows of Pascal's triangle.For example, given numRows = 5,Return[ [1], [1,1], [1,2,1]原创 2017-01-05 23:14:12 · 446 阅读 · 0 评论 -
Leetcode刷题记—— 81. Search in Rotated Sorted Array II(在翻转数组中查找2)
一、题目叙述:Follow up for "Search in Rotated Sorted Array":What if duplicates are allowed?Would this affect the run-time complexity? How and why?原创 2017-01-05 13:32:36 · 300 阅读 · 0 评论 -
Leetcode刷题记—— Search a 2D Matrix(在二维数组里查找)
一、题目叙述: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原创 2016-12-27 22:43:04 · 357 阅读 · 0 评论 -
Leetcode刷题记——16. 3Sum Closest(最接近的三个数的和)
一、题目叙述:iven 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 integers. You may assume原创 2016-11-06 22:00:29 · 325 阅读 · 0 评论 -
Leetcode刷题记——21. Merge Two Sorted Lists(合并两有序链表)
一、题目叙述: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.Subscribe to see which companies原创 2016-10-25 15:26:25 · 350 阅读 · 0 评论 -
Leetcode刷题记——20. Valid Parentheses (有效的括号即括号匹配)
一、题目叙述:Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.The brackets must close in the correct order, "()" an原创 2016-10-25 13:17:25 · 451 阅读 · 0 评论 -
Leetcode刷题记——13. Roman to Integer(罗马数字转换阿拉伯数字)
一、题目叙述:Given a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1 to 3999.Subscribe to see which companies asked this question二原创 2016-10-13 23:18:58 · 364 阅读 · 0 评论 -
Leetcode刷题记——19. Remove Nth Node From End of List(删除链表倒数第N项)
一、题目叙述: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. After removing the second nod原创 2016-10-24 19:02:20 · 199 阅读 · 0 评论 -
Leetcode刷题记——5. Longest Palindromic Substring
一、题目叙述:Given a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 1000, and there exists one unique longest palindromic substring.原创 2016-09-27 19:47:18 · 225 阅读 · 0 评论 -
Leetcode刷题记——3. Longest Substring Without Repeating Characters
一、题目叙述:Given a string, find the length of the longest substring without repeating characters.Examples:Given "abcabcbb", the answer is "abc", which the length is 3.Given "bbbb原创 2016-09-26 17:12:33 · 264 阅读 · 0 评论 -
Leetcode刷题记——2. Add Two Numbers
一、题目叙述: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 single digit. Add the two numbers and retu原创 2016-09-25 21:50:55 · 245 阅读 · 0 评论 -
Leetcode刷题记——7. Reverse Integer
一、题目叙述:Reverse digits of an integer.Example1: x = 123, return 321Example2: x = -123, return -321二、解题思路:我真的灰常灰常……醉,这题我提交到第四次才对。呜呜~不要嘲笑我啦,我自己也很难过。分析原因,一看题就知道这么简单,无非就是用整除取余把数字原创 2016-09-21 23:01:10 · 259 阅读 · 0 评论