leetcode
weixin_43371383
这个作者很懒,什么都没留下…
展开
-
leetcode Day29----array.easy
Maximize Distance to Closest PersonIn 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 si...原创 2019-05-07 22:00:46 · 149 阅读 · 0 评论 -
leetcode Day31----array.easy
Sort Array By ParityGiven an array A of non-negative integers, return an array consisting of all the even elements of A, followed by all the odd elements of A.You may return any answer array that sa...原创 2019-05-09 18:34:17 · 108 阅读 · 0 评论 -
leetcode Day22----array.easy
Find Pivot IndexGiven an array of integers nums, write a method that returns the “pivot” index of this array.We define the pivot index as the index where the sum of the numbers to the left of the in...原创 2019-04-30 22:05:20 · 90 阅读 · 0 评论 -
leetcode Day28----array.easy
Magic Squares In GridA 3 x 3 magic square is a 3 x 3 grid filled with distinct numbers from 1 to 9 such that each row, column, and both diagonals all have the same sum.Given an grid of integers, how...原创 2019-05-06 11:23:30 · 89 阅读 · 0 评论 -
leetcode Day30----array.easy
Monotonic ArrayAn array is monotonic if it is either monotone increasing or monotone decreasing.An array A is monotone increasing if for all i <= j, A[i] <= A[j]. An array A is monotone decre...原创 2019-05-08 18:42:18 · 88 阅读 · 0 评论 -
leetcode Day33----array.easy
Add to Array-Form of IntegerFor a non-negative integer X, the array-form of X is an array of its digits in left to right order. For example, if X = 1231, then the array form is [1,2,3,1].Given the ...原创 2019-05-27 13:24:50 · 129 阅读 · 0 评论 -
leetcode Day32----array.easy
Valid Mountain ArrayGiven an array A of integers, return true if and only if it is a valid mountain array.Recall that A is a mountain array if and only if:A.length >= 3There exists some i with ...原创 2019-05-27 13:23:51 · 129 阅读 · 0 评论 -
leetcode Day27----array.easy
Flipping an ImageGiven 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 rev...原创 2019-05-05 21:51:36 · 131 阅读 · 0 评论 -
leetcode Day21----array.easy
1-bit and 2-bit CharactersWe have two special characters. The first character can be represented by one bit 0. The second character can be represented by two bits (10 or 11).Now given a string repre...原创 2019-04-29 19:29:18 · 89 阅读 · 0 评论 -
leetcode Day16----array.easy
Shortest Unsorted Continuous SubarrayGiven 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 as...原创 2019-04-24 22:56:21 · 105 阅读 · 0 评论 -
leetcode Day18----array.easy
Maximum Product of Three NumbersGiven an integer array, find three numbers whose product is maximum and output the maximum product.Example 1:Input: [1,2,3]Output: 6Example 2:Input: [1,2,3,4]Out...原创 2019-04-26 14:18:45 · 97 阅读 · 0 评论 -
leetcode Day6----array.easy
Merge Sorted Array原创 2019-04-14 15:22:42 · 80 阅读 · 1 评论 -
leetcode Day8----array.easy
Best Time to Buy and Sell StockSay 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 (i.e., buy one an...原创 2019-04-16 23:15:27 · 93 阅读 · 0 评论 -
leetcode Day17----array.easy
Can Place FlowersSuppose you have a long flowerbed in which some of the plots are planted and some are not. However, flowers cannot be planted in adjacent plots - they would compete for water and bot...原创 2019-04-25 22:19:51 · 73 阅读 · 0 评论 -
leetcode Day13----array.easy
Missing NumberGiven an array containing n distinct numbers taken from 0, 1, 2, …, n, find the one that is missing from the array.Example 1:Input: [3,0,1]Output: 2Example 2:Input: [9,6,4,2,3,5,7,...原创 2019-04-21 10:37:08 · 119 阅读 · 0 评论 -
leetcode Day5----array.easy
Maximum SubarrayGiven 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],Outpu...原创 2019-04-13 16:02:02 · 111 阅读 · 0 评论 -
leetcode Day1----array.easy
int* twoSum(int* nums, int numsSize, int target) { int answer[2] = {0}; for (int i = 0 ; i < numsSize; i++){ for (int j = i+1 ; j < numsSize ; j++){ if((nums [i] + nums [j]) == target){ answer[0] = i;原创 2019-04-09 23:32:56 · 71 阅读 · 1 评论 -
leetcode Day4----array.easy
Search Insert PositionGiven 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 dupl...原创 2019-04-12 22:31:44 · 70 阅读 · 0 评论 -
leetcode Day7----array.easy
Pascal’s TriangleGiven 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:In...原创 2019-04-15 16:49:30 · 144 阅读 · 0 评论 -
leetcode Day3----array.easy
Remove ElementGiven an array nums and a value val, 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 by modifying ...原创 2019-04-11 22:30:29 · 66 阅读 · 0 评论 -
leetcode Day14----array.easy
Find All Numbers Disappeared in an ArrayGiven 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...原创 2019-04-22 16:20:20 · 95 阅读 · 0 评论 -
leetcode Day9----array.easy
在刷题之前,折腾好了第一个github项目,学会了上传以前的一个代码。https://github.com/sensegirl/HUAWEI2019codecraft用github desktop桌面版传还是遇到了些问题,用下面的方法上传成功。附知乎链接:https://zhuanlan.zhihu.com/p/34625448Two Sum II - Input array is sor...原创 2019-04-17 20:17:42 · 94 阅读 · 0 评论 -
leetcode Day26----array.easy
Positions of Large GroupsIn a string S of lowercase letters, these letters form consecutive groups of the same character.For example, a string like S = “abbxxxxzyy” has the groups “a”, “bb”, “xxxx”,...原创 2019-05-04 22:57:47 · 85 阅读 · 0 评论 -
leetcode Day12----array.easy
Shortest Word Distance原创 2019-04-20 11:45:11 · 69 阅读 · 0 评论 -
leetcode Day11----array.easy
Contains DuplicateGiven 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 ...原创 2019-04-19 23:07:53 · 98 阅读 · 0 评论 -
leetcode Day25----array.easy
Toeplitz MatrixA 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:Inpu...原创 2019-05-03 23:05:21 · 135 阅读 · 2 评论 -
leetcode Day15----array.easy
K-diff Pairs in an ArrayGiven an array of integers and an integer k, you need to find the number of unique k-diff pairs in the array. Here a k-diff pair is defined as an integer pair (i, j), where i ...原创 2019-04-23 21:05:30 · 131 阅读 · 0 评论 -
leetcode Day20----array.easy
Non-decreasing ArrayGiven an array with n integers, your task is to check if it could become non-decreasing by modifying at most 1 element.We define an array is non-decreasing if array[i] <= arra...原创 2019-04-28 11:18:46 · 126 阅读 · 0 评论 -
leetcode Day24----array.easy
Largest Number At Least Twice of OthersIn a given integer array nums, there is always exactly one largest element.Find whether the largest element in the array is at least twice as much as every oth...原创 2019-05-02 21:37:07 · 104 阅读 · 0 评论 -
leetcode Day19----array.easy
Image SmootherGiven a 2D integer matrix M representing the gray scale of an image, you need to design a smoother to make the gray scale of each cell becomes the average gray scale (rounding down) of ...原创 2019-04-27 21:20:59 · 78 阅读 · 0 评论 -
leetcode Day23----array.easy
Min Cost Climbing StairsOn a staircase, the i-th step has some non-negative cost cost[i] assigned (0 indexed).Once you pay the cost, you can either climb one or two steps. You need to find minimum c...原创 2019-05-01 22:50:17 · 96 阅读 · 0 评论 -
leetcode Day10----array.easy
Majority ElementGiven 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 major...原创 2019-04-18 15:44:51 · 107 阅读 · 0 评论 -
leetcode Day2----array.easy
Remove Duplicates from Sorted ArrayGiven a sorted array nums, remove the duplicates in-place such that each element appear only once and return the new length.Do not allocate extra space for another...原创 2019-04-10 20:13:37 · 98 阅读 · 0 评论