![](https://img-blog.csdnimg.cn/20201014180756913.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
面试题
xiaonaughty
这个作者很懒,什么都没留下…
展开
-
[LeetCode]485 Max Consecutive Ones
Given a binary array, find the maximum number of consecutive 1s in this array.Example 1:Input: [1,1,0,1,1,1]Output: 3Explanation: The first two digits or the last three digits are consecutiv原创 2017-01-16 11:14:57 · 184 阅读 · 0 评论 -
[LeetCode]66 Plus One
Given a non-negative integer represented as a non-empty array of digits, plus one to the integer.You may assume the integer do not contain any leading zero, except the number 0 itself.The digi原创 2017-02-14 16:16:13 · 213 阅读 · 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) to hold addit原创 2017-02-14 17:35:31 · 247 阅读 · 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], [1,3,3,1], [1,4,6,4,1]]Solution in Java原创 2017-03-03 11:11:24 · 217 阅读 · 0 评论 -
[LeetCode]119 Pascal's Triangle II
Given an index k, return the kth row of the Pascal's triangle.For example, given k = 3,Return [1,3,3,1].Note:Could you optimize your algorithm to use only O(k) extra space?My 8 lines原创 2017-03-03 17:16:25 · 206 阅读 · 0 评论 -
[LeetCode]121 Best Time to Buy and Sell Stock
Say you have an array for which the ith element is the price of a given stock on day i.If you were only permitted to complete at most one transaction (ie, buy one and sell one share of the stock),原创 2017-03-03 18:08:57 · 208 阅读 · 0 评论 -
[LeetCode]122 Best Time to Buy and Sell Stock II
Say you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may complete as many transactions as you like (ie, buy on原创 2017-03-05 11:29:12 · 184 阅读 · 0 评论 -
[LeetCode]520 Detect Capital
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 one of the following cases holds:All letters in t原创 2017-03-05 12:03:22 · 318 阅读 · 0 评论 -
[LeetCode]2 Add Two Numbers
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 contain a single digit. Add the two numbers and return i原创 2017-03-06 15:32:51 · 273 阅读 · 0 评论 -
[LeetCode]344 Reverse String
Write a function that takes a string as input and returns the string reversed.Example:Given s = "hello", return "olleh".[JAVA] Simple and Clean with Explanations [6 Solutions]原创 2017-03-06 16:03:50 · 244 阅读 · 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 "bbbbb", the answer is "原创 2017-03-06 17:57:06 · 287 阅读 · 0 评论 -
[LeetCode]7 Reverse Integer
Reverse digits of an integer.Example1: x = 123, return 321Example2: x = -123, return -321click to show spoilers.Have you thought about this?Here are some good questions to ask before c原创 2017-03-06 18:13:08 · 284 阅读 · 0 评论 -
[LeetCode]9. Palindrome Number
Determine whether an integer is a palindrome. Do this without extra space.Some hints:Could negative integers be palindromes? (ie, -1)If you are thinking of converting the integer to string,原创 2017-03-07 10:53:25 · 276 阅读 · 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 subarray [4,-1,2,1] ha原创 2017-02-14 10:23:41 · 200 阅读 · 0 评论 -
[LeetCode]219 Contains Duplicate II
Given an array of integers and an integer k, find out whether there are two distinct indices i and j in the array such that nums[i] = nums[j] and the absolute difference between i and j is a原创 2017-01-24 10:41:42 · 195 阅读 · 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 order.You may assume no duplicates in the array.原创 2017-02-13 10:52:12 · 246 阅读 · 0 评论 -
[LeetCode]189 Rotate Array
Rotate an array of n elements to the right by k steps.For example, with n = 7 and k = 3, the array [1,2,3,4,5,6,7] is rotated to [5,6,7,1,2,3,4].Note:Try to come up as many solutions as yo原创 2017-02-07 15:03:49 · 272 阅读 · 0 评论 -
[LeetCode]448 Find All Numbers Disappeared in an Array
Given an array of integers where 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once.Find all the elements of [1, n] inclusive that do not appear in this array.原创 2017-01-16 15:41:49 · 226 阅读 · 0 评论 -
[LeetCode]442 Find All Duplicates in an Array
Given an array of integers, 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once.Find all the elements that appear twice in this array.Could you do it without ex原创 2017-01-16 16:20:12 · 181 阅读 · 0 评论 -
[LeetCode]169 Majority Element
Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times.You may assume that the array is non-empty and the majority elem原创 2017-02-08 10:17:26 · 175 阅读 · 0 评论 -
[LeetCode]1 Two Sum
Given an array of integers, return indices of the two numbers such that they add up to a specific target.You may assume that each input would have exactly one solution, and you may not use the sam原创 2017-02-08 11:16:27 · 198 阅读 · 0 评论 -
[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 number原创 2017-02-08 11:43:34 · 178 阅读 · 0 评论 -
[LeetCode]414 Third Maximum Number
Given a non-empty array of integers, return the third maximum number in this array. If it does not exist, return the maximum number. The time complexity must be in O(n).Example 1:Input: [3, 2,原创 2017-01-16 18:19:34 · 394 阅读 · 0 评论 -
[LeetCode]283 Move Zeroes
Given an array nums, write a function to move all 0's to the end of it while maintaining the relative order of the non-zero elements.For example, given nums = [0, 1, 0, 3, 12], after calling原创 2017-01-18 09:53:11 · 196 阅读 · 0 评论 -
[LeetCode]268 Missing Number
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 = [0, 1, 3] return 2.Note:Your algorithm shoul原创 2017-02-09 10:23:01 · 227 阅读 · 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 must do this in place with原创 2017-02-09 11:30:06 · 168 阅读 · 0 评论 -
[LeetCode]217 Contains Duplicate
Given an array of integers, find if the array contains any duplicates. Your function should return true if any value appears at least twice in the array, and it should return false if every element原创 2017-01-19 09:57:54 · 195 阅读 · 0 评论 -
[LeetCode]27 Remove Element
Given an array and a value, remove all instances of that value in place and return the new length.Do not allocate extra space for another array, you must do this in place with constant memory.原创 2017-02-13 10:08:10 · 235 阅读 · 0 评论 -
[LeetCode]125. Valid Palindrome
Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.For example,"A man, a plan, a canal: Panama" is a palindrome."race a car" is not a原创 2017-03-07 11:08:57 · 337 阅读 · 0 评论