LeetCode Maximum Subarray
Problem Find the contiguous subarray within an array (containing at least one number) which has the largest sum. For example, given the array [-2,1,-3,4,-1,2,1,-5,4], the contiguous subarray [4,-...
Problem Find the contiguous subarray within an array (containing at least one number) which has the largest sum. For example, given the array [-2,1,-3,4,-1,2,1,-5,4], the contiguous subarray [4,-...
Problem The count-and-say sequence is the sequence of integers with the first five terms as following: 1 11 21 1211 111221 1 is read off as “one 1” or 11. 11 is read off as “two 1s” ...
Problem Implement strStr(). Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack. 题目其实就是实现Java中String的indexOf函数。因此,直接调用该方法,显然是不合适的。 Java 实现...
Problem Given an array and a value, 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 in place with constant m...
Problem 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 ...
Problem 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. 即合并两个已经排好序的链表。并且要求返回的新链表是由原两个链表元素组合而成的。链表的结构定...
Problem Given a string containing just the characters ‘(‘, ‘)’, ‘{‘, ‘}’, ‘[’ and ‘]’, determine if the input string is valid. The brackets must close in the correct order, “()” and “()[]{}” are ...
Problem Write a function to find the longest common prefix string amongst an array of strings. 就是找出一个字符串数组中元素,最长的通用前缀。例如:{“ab”,”abc”,”abd”},答案是 “ab”。 Java 实现 package com.coderli.leetcode.alg...
Problem Given an integer, convert it to a roman numeral. Input is guaranteed to be within the range from 1 to 3999. 跟Roman To Integer是对应问题。即将整数转换成对应的罗马数字。罗马数字规则见wiki:罗马数字规则 Java 实现(个人解法) pa...
Problem Given a roman numeral, convert it to an integer. Input is guaranteed to be within the range from 1 to 3999. 即将罗马数字1-3999转换成对应的整数。罗马数字规则见wiki:罗马数字规则 Java 实现 /** * Given a roman nume...