EASY
YuanTheCoder
转码之路
展开
-
Leetcode 922. Sort Array By Parity II , Java解法
Given an arrayAof non-negative integers, half of the integers in A are odd, and half of the integers are even.Sort the array so that wheneverA[i]is odd,iis odd; and wheneverA[i]is even,iis...原创 2019-07-12 20:10:22 · 358 阅读 · 0 评论 -
Leetcode 1089. Duplicate Zeros, java解法 及Queue的使用
Given a fixed lengtharrayarrof integers, duplicate each occurrence of zero, shifting the remaining elements to the right.Note that elements beyond the length of the original array are not written...原创 2019-07-20 17:21:58 · 297 阅读 · 0 评论 -
Leetcode 1051. Height Checker, Java解法
Students are asked to stand in non-decreasing order of heights for an annual photo.Return the minimum number of students not standing in the right positions. (This is the number of students that mu...原创 2019-07-12 14:40:32 · 533 阅读 · 1 评论 -
Leetcode 561. Array Partition I, Java解法
Given an array of2nintegers, your task is to group these integers intonpairs 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 poss...原创 2019-07-12 12:37:46 · 251 阅读 · 0 评论 -
Leetcode 977. Squares of a Sorted Array, Java解法
Given an array of integersAsorted in non-decreasing order,return an array of the squares of each number,also in sorted non-decreasing order.Example 1:Input: [-4,-1,0,3,10]Output: [0,1,9,16,1...原创 2019-07-12 11:16:39 · 358 阅读 · 0 评论 -
Leetcode 905. Sort Array By Parity, Java解法
Given an arrayAof non-negative integers, return an array consisting of all the even elements ofA, followed by all the odd elements ofA.You may return any answer array that satisfies this conditi...原创 2019-07-12 10:34:30 · 194 阅读 · 0 评论 -
Leetcode 832. Flipping an Image, Java解法
Given a binary matrixA, 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...原创 2019-07-12 10:01:35 · 165 阅读 · 0 评论 -
Leetcode 1085. Sum of Digits in the Minimum Number, Java解法
Given an arrayAof positive integers, letSbe the sum of the digits of the minimal element ofA.Return 0 ifSis odd, otherwise return 1.Example 1:Input: [99,77,33,66,55]Output: 1Explana...原创 2019-07-11 20:03:08 · 236 阅读 · 0 评论 -
Leetcode 283. Move Zeroes java解法
Given an arraynums, write a function to move all0'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...原创 2019-07-16 08:58:48 · 259 阅读 · 0 评论 -
Leetcode 1119. Remove Vowels from a String, Java解法
Given a stringS, remove the vowels'a','e','i','o', and'u'from it, and return the new string.Example 1:Input: "leetcodeisacommunityforcoders"Output: "ltcdscmmntyfrcdrs"Example 2:Inpu...原创 2019-07-15 23:52:40 · 299 阅读 · 0 评论 -
Leetcode 1. Two Sum, Java 解法
Given an array of integers, returnindicesof the two numbers such that they add up to a specific target.You may assume that each input would haveexactlyone solution, and you may not use thesame...原创 2019-07-10 20:15:22 · 191 阅读 · 0 评论 -
Leetcode 867. Transpose Matrix, Java解法
Given amatrixA, return the transpose ofA.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]...原创 2019-07-14 21:11:57 · 170 阅读 · 0 评论 -
Leetcode 1064. Fixed Point, Java解法
Given an arrayAof distinct integers sorted in ascending order, return the smallest indexithat satisfiesA[i] == i. Return-1if no suchiexists.Example 1:Input: [-10,-5,0,3,7]Output: 3...翻译 2019-07-10 14:22:34 · 753 阅读 · 0 评论 -
Leetcode 760. Find Anagram Mappings, java解法
Given two listsAandB, andBis an anagram ofA.Bis an anagram ofAmeansBis made by randomizing the order of the elements inA.We want to find anindex mappingP, fromAtoB. A mappingP[i] =...原创 2019-07-10 13:51:48 · 165 阅读 · 0 评论 -
Leetcode 509. Fibonacci Number , Java 解法
TheFibonacci numbers, commonly denotedF(n)form a sequence, called theFibonacci sequence, such that each number is the sum of the two preceding ones, starting from0and1. That is,F(0) = 0, F(...原创 2019-07-14 09:08:49 · 378 阅读 · 0 评论 -
Leetcode 771. Jewels and Stones Java解法
You're given stringsJrepresenting the types of stones that are jewels, andSrepresenting the stones you have. Each character inSis a type of stone you have. You want to know how many of the ston...翻译 2019-07-05 23:59:35 · 200 阅读 · 0 评论 -
Leetcode 1108. Defanging an IP Address, Java解法
Given a valid (IPv4) IPaddress, return a defanged version of that IP address.AdefangedIP addressreplaces every period"."with"[.]".Example 1:Input: address = "1.1.1.1"Output: "1[.]1[....原创 2019-07-09 23:43:23 · 475 阅读 · 0 评论 -
leetcode 70. Climbing Stairs Java解法,Amazon面试
You are climbing a stair case. It takesnsteps 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:Givennwill be a positive...原创 2019-08-22 10:39:58 · 169 阅读 · 0 评论