leetcode 66 Plus One

2017-05-23
阅读 1 分钟
2.1k
Given a non-negative integer represented as a non-empty array of digits, plus one to the integer.You may assume the integer do not contain any leading zero, except the number 0 itself.The digits are stored such that the most significant digit is at the head of the list.

leetcode _58 length of the last word

2017-05-22
阅读 1 分钟
1.3k
先求出去掉首位空格后,找到最后一次出现空格(即出现最后一个词的分割)的index,然后用总长度减去前面的所有字节的长度,既获得了最后一个单词的长度

leetcode 38 count and say

2017-04-28
阅读 2 分钟
1.7k
The count-and-say sequence is the sequence of integers with the first five terms as following:1112112111112211 is read off as "one 1" or 11.11 is read off as "two 1s" or 21.21 is read off as "one 2, then one 1" or 1211.Given an integer n, generate the nth term of the count-and-say sequence. 这道...

leetcode_35_SearchInsertPosition

2017-04-16
阅读 1 分钟
1.4k
题目描述: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.给定一个排序好的数组和一个目标,找出目标在数组中的位置或者他应该在的位置

leetcode 26 Remove Duplicates from Sorted Array

2017-04-14
阅读 1 分钟
1.6k
Given a sorted array, 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 in place with constant memory.For example,Given input array nums = [1,1,2],Your function should return length = 2,...

Leetcode 21 Merge Two Sorted Lists

2017-04-04
阅读 1 分钟
1.9k
Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists.题目要求我们将两个有序链表合成一个有序的链表。 Example:输入: 1->2->4, 1->3->4输出: 1->1->2->3->4->4

leetcode 14 Longest Common Prefix

2017-04-01
阅读 1 分钟
2.1k
Write a function to find the longest common prefix string amongst an array of strings. 题目要求是,给定一个字符串的数组,我们要找到所有字符串所共有的最长的前缀。