LeetCode Implement strStr()
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 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...
Problem Determine whether an integer is a palindrome. Do this without extra space. 即返回一个数是否是回数。例如:1,1221,12321是回数,负数不是回数。题目特别提醒,不要使用额外的空间,即不要考虑转换成String来处理。 Java 实现 /** * Determine whether ...
Problem Reverse digits of an integer. Example1: x = 123, return 321 Example2: x = -123, return -321 Note: The input is assumed to be a 32-bit signed integer. Your function should return 0 when t...