我的代码游记

归档 · 2017

首页

关于

归档

计数LeetCodeMedium数组

80.Remove Duplicates from Sorted Array II(Medium)

Follow up for “Remove Duplicates”:What if duplicates are allowed at most twice?给定一个有序的整数数列,每个数最多只能出现两次,然后去除多余的数,把剩下的数排在原数组的前面,并返回新数列的长度 *  这虽然是个中等题,不过难度不大,唯一需要多考虑的就是在原数组前面排列新的数组* For example Given sorted array nums = [1,1,1,2,2,3],Your function should return length = 5, with the first five elements of nums being 1, 1, 2, 2 and 3. It doesn’t matter what ..

更多
loading..
搜索LeetCodeEasy一行实现

500.Keyboard Row(Easy)

Given a List of words, return the words that can be typed using letters of alphabet on only one row’s of American keyboard like the image below. *  虽然还把键盘搬出来了,但是实际上只是搜索每一个String的字母是否在键盘的同一行出现,键盘的每一行只要用一个String代替就ok了,剩下的问题显然就简单了。* For example Input: [“Hello”, “Alaska”, “Dad”, “Peace”]Output: [“Alaska”, “Dad”] My Solution(Java) Version 1 Time: 3ms:  简单..

更多
LeetCodeEasy二分查找

374.Guess Number Higher or Lower(Easy)

We are playing the Guess Game. The game is as follows:I pick a number from 1 to n. You have to guess which number I picked.Every time you guess wrong, I’ll tell you whether the number is higher or lower.You call a pre-defined API guess(int num) which returns 3 possible results (-1, 1, or 0):我们来玩一个猜数游戏,游戏规则是这样的:我从1~n中选择一个数,你需要猜我选的数是哪一个,如果你猜错的话,我就会告诉你你猜的数比我..

更多