leetcode
Felaim
每天进步一点点o(* ̄▽ ̄*)ブ
展开
-
LeetCode:66.plus one
开始刷leetcode了,下半年要开始找工作了。。。不然肯定被各路大神碾压了,加油,Felaim!一下午都在矫正机器人,然后发现机器人因为闲置太久了,轮胎没气了都,所以driftfactor一直都很大。最后才发现这个问题,立马淘宝下单买打气筒,可能矫正任务要先放一放,最后总结一个教程吧,硬件的尴尬比软件多的多。。。进入正题,按照tag来刷leetcode的,第一题是Plus one。代...原创 2018-05-02 19:47:11 · 343 阅读 · 0 评论 -
Leetcode:766. Toeplitz Matrix
问题描述: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: mat...原创 2018-05-26 15:08:19 · 344 阅读 · 0 评论 -
Leetcode:717. 1-bit and 2-bit Characters
问题描述:We 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 represented by several bit...原创 2018-06-02 17:27:18 · 290 阅读 · 0 评论 -
Leetcode:566. Reshape the Matrix
问题描述: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-...原创 2018-05-26 22:49:32 · 251 阅读 · 0 评论 -
Leercode: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...原创 2018-06-03 15:00:36 · 348 阅读 · 0 评论 -
Leetcode:485. Max Consecutive Ones
问题描述:485. Max Consecutive OnesExample 1:Input: [1,1,0,1,1,1]Output: 3Explanation: The first two digits or the last three digits are consecutive 1s. The maximum number of consecutive 1s is ...原创 2018-05-27 15:20:49 · 264 阅读 · 0 评论 -
Leetcode:695. Max Area of Island
问题描述:Given a non-empty 2D array grid of 0’s and 1’s, an island is a group of 1’s (representing land) connected 4-directionally (horizontal or vertical.) You may assume all four edges of the grid are s...原创 2018-05-27 17:28:30 · 282 阅读 · 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 (i.e...原创 2018-06-03 15:49:50 · 242 阅读 · 0 评论 -
Leetcode:830. Positions of Large Groups
问题描述:In 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”, “z” and “yy”.Call...原创 2018-06-03 16:51:47 · 413 阅读 · 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.Example:Input: [0,1,0,3,12]Output: [1,3,12,0,0]Note:...原创 2018-05-30 22:22:43 · 229 阅读 · 0 评论 -
leetcode:561. Array Partition I
问题描述: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 p...原创 2018-05-26 11:42:29 · 288 阅读 · 0 评论 -
Leetcode:832. Flipping an Image
问题描述: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 ...原创 2018-05-25 23:22:23 · 895 阅读 · 0 评论 -
LeetCode:11. Container With Most Water
题目表述:Given n non-negative integers a1, a2, …, an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i, 0). Find t...原创 2018-05-03 10:40:09 · 309 阅读 · 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 ...原创 2018-05-03 15:27:46 · 228 阅读 · 0 评论 -
Leetcode:15. 3Sum
问题描述:Given an array nums of n integers, are there elements a, b, c in nums such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.其实就是给定一个数组,没有按顺序排列,找到三个数的和等于0,且这...原创 2018-05-12 12:24:29 · 233 阅读 · 0 评论 -
Leetcode:16. 3Sum Closest
问题描述: Given an array nums of n integers and an integer target, find three integers in nums such that the sum is closest to target. Return the sum of the three integers. You may assume that each input...原创 2018-05-19 16:04:58 · 351 阅读 · 0 评论 -
Leetcode:18. 4Sum
问题描述: Given an array nums of n integers and an integer target, are there elements a, b, c, and d in nums such that a + b + c + d = target? Find all unique quadruplets in the array which gives the sum...原创 2018-05-19 18:17:36 · 253 阅读 · 0 评论 -
Leetcode:26. Remove Duplicates from Sorted Array
问题描述: Given 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 array, you must do this by ...原创 2018-05-20 09:38:49 · 386 阅读 · 0 评论 -
LeetCode -- reference binding to null pointer of type 'value_type'
在刷leetcode的时候出现了如题目的问题,LZ在run自己代码的时候是OK的,但是在submit的时候会报错,为何会出现如下原因呢?在提交的时候leetcode会测试各种的情况,在某些情况下LZ考虑情况没有很全面,这就导致最后对于某些情况代码运行不通过,例如向量越界等问题.class Solution {public: int removeDuplicates(vecto...原创 2018-05-20 09:53:44 · 5948 阅读 · 1 评论 -
Leetcode:27. Remove Element
问题描述:Given 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 the input...原创 2018-05-20 10:43:43 · 256 阅读 · 0 评论 -
Leetcode:31. Next Permutation
问题描述:Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.If such arrangement is not possible, it must rearrange it as the lowest possi...原创 2018-05-21 20:24:13 · 303 阅读 · 3 评论 -
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...原创 2018-05-30 23:27:26 · 313 阅读 · 0 评论