![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
leetcode
文章平均质量分 52
DurianPudding
这个作者很懒,什么都没留下…
展开
-
leetcode 561 Array Partition I -Java(Arrays.sort())
Given an array of 2n integers, your task is to group these integers into n pairs of integer, say (a1, b1), (a2, b2), …, (an, bn) which makes sum of min(ai, bi) for all i from 1 to n as large as possib...原创 2018-08-22 10:18:19 · 220 阅读 · 0 评论 -
leetcode 709. To Lower Case(水,大写转小写)
Implement function ToLowerCase() that has a string parameter str, and returns the same string in lowercase.Example 1:Input: “Hello”Output: “hello”Example 2:Input: “here”Output: “here”Example 3:...原创 2018-09-25 19:38:14 · 158 阅读 · 0 评论 -
leetcode 804. Unique Morse Code Words(String、char、HashSet、ASC2)
International Morse Code defines a standard encoding where each letter is mapped to a series of dots and dashes, as follows: “a” maps to “.-”, “b” maps to “-…”, “c” maps to “-.-.”, and so on.For conv...原创 2018-09-25 21:20:40 · 149 阅读 · 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 same e...原创 2018-09-20 15:53:24 · 99 阅读 · 0 评论 -
leetcode 849. Maximize Distance to Closest Person(分析复杂)
In a row of seats, 1 represents a person sitting in that seat, and 0 represents that the seat is empty.There is at least one empty seat, and at least one person sitting.Alex wants to sit in the seat...原创 2018-09-20 17:01:37 · 187 阅读 · 0 评论 -
leetcode 657. Robot Return to Origin(水)
There is a robot starting at position (0, 0), the origin, on a 2D plane. Given a sequence of its moves, judge if this robot ends up at (0, 0) after it completes its moves.The move sequence is represe...原创 2018-09-26 10:33:18 · 322 阅读 · 0 评论 -
leetcode 520. Detect Capital(char,arraylist)
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 this wo...原创 2018-09-26 11:23:02 · 136 阅读 · 0 评论 -
leetcode 581. Shortest Unsorted Continuous Subarray(思路,数组复制)
Given an integer array, you need to find one continuous subarray that if you only sort this subarray in ascending order, then the whole array will be sorted in ascending order, too.You need to find t...原创 2018-09-21 10:41:14 · 144 阅读 · 0 评论 -
leetcode 189. Rotate Array(Linkedlist)
Given an array, rotate the array to the right by k steps, where k is non-negative.Example 1:Input: [1,2,3,4,5,6,7] and k = 3Output: [5,6,7,1,2,3,4]Explanation:rotate 1 steps to the right: [7,1,2,...原创 2018-09-22 15:48:47 · 125 阅读 · 0 评论 -
leetcode 459. Repeated Substring Pattern(思路麻烦,子串)
Given a non-empty string check if it can be constructed by taking a substring of it and appending multiple copies of the substring together. You may assume the given string consists of lowercase Engli...原创 2018-10-17 23:03:55 · 193 阅读 · 0 评论 -
leetcode 383. Ransom Note(思路,++i i++的区别,String)
Given an arbitrary ransom note string and another string containing letters from all the magazines, write a function that will return true if the ransom note can be constructed from the magazines ; ot...原创 2018-10-16 21:12:01 · 223 阅读 · 1 评论 -
leetcode 557. Reverse Words in a String III(String、StringBuilder)
Given a string, you need to reverse the order of characters in each word within a sentence while still preserving whitespace and initial word order.Example 1:Input: “Let’s take LeetCode contest”Out...原创 2018-09-25 15:50:55 · 108 阅读 · 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.Ex...原创 2018-09-19 10:38:25 · 145 阅读 · 0 评论 -
leetcode 53 Maximum Subarray (思路难!归纳法分治法)
Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum.Example:Input: [-2,1,-3,4,-1,2,1,-5,4],Output: 6Explanation:...原创 2018-09-18 21:39:38 · 450 阅读 · 0 评论 -
leetcode 867. Transpose Matrix(二维数组)
Given a matrix A, return the transpose of A.The transpose of a matrix is the matrix flipped over it’s main diagonal, switching the row and column indices of the matrix.Example 1:Input: [[1,2,3],...原创 2018-08-22 11:31:27 · 198 阅读 · 0 评论 -
leetcode 766. Toeplitz Matrix -java
A matrix is Toeplitz if every diagonal from top-left to bottom-right has the same element.Now given an M x N matrix, return True if and only if the matrix is Toeplitz.Example 1:Input: matrix = ...原创 2018-08-22 16:30:05 · 209 阅读 · 0 评论 -
leetcode832 Flipping an Image(翻转图像)-java
Given a binary matrix A, we want to flip the image horizontally, then invert it, and return the resulting image.To flip an image horizontally means that each row of the image is reversed. For examp...原创 2018-08-21 15:48:53 · 197 阅读 · 0 评论 -
leetcode 566Reshape the Matrix -java
In MATLAB, there is a very useful function called ‘reshape’, which can reshape a matrix into a new one with different size but keep its original data.You’re given a matrix represented by a two-dimen...原创 2018-09-03 16:02:08 · 145 阅读 · 0 评论 -
leetcode485. Max Consecutive Ones -java
Given a binary array, find the maximum number of consecutive 1s in this array.Example 1: Input: [1,1,0,1,1,1] Output: 3 Explanation: The first two digits or the last three digits are consecutive ...原创 2018-09-03 22:02:42 · 122 阅读 · 0 评论 -
leetcode283. 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.Example:Input: [0,1,0,3,12] Output: [1,3,12,0,0] Note:You m...原创 2018-09-03 22:50:04 · 122 阅读 · 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 element alwa...原创 2018-09-06 20:39:52 · 122 阅读 · 0 评论 -
leetcode 217 Contains Duplicate -(Hashset)
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 i...原创 2018-09-12 18:10:05 · 159 阅读 · 0 评论 -
leetcode 167. Two Sum II - Input array is sorted -(双重循环break continue)
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 numbers ...原创 2018-09-13 10:01:42 · 95 阅读 · 0 评论 -
leetcode 118. Pascal's Triangle (ArrayList、List与思路难)
Given a non-negative integer numRows, generate the first numRows of Pascal’s triangle.In Pascal’s triangle, each number is the sum of the two numbers directly above it.Example:Input: 5Output:[[1...原创 2018-09-18 20:13:06 · 159 阅读 · 0 评论 -
leetcode 387. First Unique Character in a String(String和数组结合,思路)
Given a string, find the first non-repeating character in it and return it’s index. If it doesn’t exist, return -1.Examples:s = “leetcode”return 0.s = “loveleetcode”,return 2.题意:找到第一个唯一的字母的索引思...原创 2018-10-16 22:15:53 · 143 阅读 · 0 评论