String
文章平均质量分 65
豆腐脑是咸的
这个作者很懒,什么都没留下…
展开
-
Multiply Strings (Java)
Given two numbers represented as strings, return multiplication of the numbers as a string.Note: The numbers can be arbitrarily large and are non-negative.先把每一位乘出来的数存起来,然后再集体处理进位。Source原创 2015-01-08 22:36:10 · 865 阅读 · 0 评论 -
Roman to Integer (Java)
Given a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1 to 3999.原创 2014-10-16 19:56:51 · 471 阅读 · 0 评论 -
ZigZag Conversion (Java)
The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility)P A H NA P L S I原创 2014-10-15 15:46:13 · 492 阅读 · 0 评论 -
Generate Parentheses (Java)
Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.For example, given n = 3, a solution set is:"((()))", "(()())", "(())()", "()(())", "()()原创 2015-01-19 10:24:06 · 400 阅读 · 0 评论 -
Longest Palindromic Substring (Java)
Given a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 1000, and there exists one unique longest palindromic substring.这道题可以套用Palindrome原创 2015-01-20 21:32:46 · 343 阅读 · 0 评论 -
Regular Expression Matching (Java)
Implement regular expression matching with support for '.' and '*'.'.' Matches any single character.'*' Matches zero or more of the preceding element.The matching should cover the entire input st原创 2015-02-07 11:21:57 · 399 阅读 · 0 评论 -
Integer to Roman (Java)
Given an integer, convert it to a roman numeral.Input is guaranteed to be within the range from 1 to 3999.罗马数字 I(1)、V(5)、X(10)、L(50)、C(100)、D(500)、M(1000)罗马数字是左减右加只需记住罗马数字转为整型数字的减操作注意事项:原创 2015-01-20 22:01:07 · 242 阅读 · 0 评论 -
Interleaving String (Java)
Given s1, s2, s3, find whether s3 is formed by the interleaving of s1 and s2.For example,Given:s1 = "aabcc",s2 = "dbbca",When s3 = "aadbbcbcac", return true.When s3 = "aadbbbaccc", ret原创 2015-02-08 10:34:20 · 339 阅读 · 0 评论 -
Longest Valid Parentheses (Java)
Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring.For "(()", the longest valid parentheses substring is "()",原创 2015-02-08 08:55:41 · 331 阅读 · 0 评论 -
Longest Substring Without Repeating Characters (Java)
Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters for "abcabcbb" is "abc", which the length is 3. Fo原创 2015-01-03 20:23:40 · 272 阅读 · 0 评论 -
Reverse Words in a String (Java)
Given an input string, reverse the string word by word.For example,Given s = "the sky is blue",return "blue is sky the".click to show clarification.Clarification:What constitutes原创 2015-01-22 09:15:02 · 424 阅读 · 0 评论 -
Simplify Path (Java)
Given an absolute path for a file (Unix-style), simplify it.For example,path = "/home/", => "/home"path = "/a/./b/../../c/", => "/c"click to show corner cases.Corner Cases:Did原创 2015-01-23 09:15:32 · 353 阅读 · 0 评论 -
Anagrams (Java)
Given an array of strings, return all groups of strings that are anagrams.Note: All inputs will be in lower-case.给定一字符串数组,返回其中是由相同字符组成只是顺序不同的字符串子数组,这些字符只出现了一次的字符串不返回。比如 abb,bab,bba,abc 返回[原创 2015-01-04 21:44:09 · 293 阅读 · 0 评论 -
Valid Number (Java)
Validate if a given string is numeric.Some examples:"0" => true" 0.1 " => true"abc" => false"1 a" => false"2e10" => trueNote: It is intended for the problem statement to be ambiguo原创 2015-02-12 14:42:02 · 457 阅读 · 0 评论 -
Valid Parentheses (Java)
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 all va原创 2014-10-28 10:07:47 · 450 阅读 · 0 评论 -
Count and Say (Java)
The count-and-say sequence is the sequence of integers beginning as follows:1, 11, 21, 1211, 111221, ...1 is read off as "one 1" or 11.11 is read off as "two 1s" or 21.21 is read off as原创 2014-10-28 19:34:09 · 438 阅读 · 0 评论 -
Distinct Subsequences (Java)
Given a string S and a string T, count the number of distinct subsequences of T in S.A subsequence of a string is a new string which is formed from the original string by deleting some (can be non原创 2015-01-29 11:52:18 · 352 阅读 · 0 评论 -
Edit Distance (Java)
Given two words word1 and word2, find the minimum number of steps required to convert word1 to word2. (each operation is counted as 1 step.)You have the following 3 operations permitted on a word:原创 2015-01-29 11:15:44 · 1053 阅读 · 0 评论 -
Decode Ways (Java)
A message containing letters from A-Z is being encoded to numbers using the following mapping:'A' -> 1'B' -> 2...'Z' -> 26Given an encoded message containing digits, determine the total nu原创 2015-01-18 14:07:04 · 338 阅读 · 0 评论 -
Restore IP Addresses (Java)
Given a string containing only digits, restore it by returning all possible valid IP address combinations.For example:Given "25525511135",return ["255.255.11.135", "255.255.111.35"]. (Order原创 2015-01-19 15:05:12 · 381 阅读 · 0 评论 -
String to Integer (atoi) (Java)
Implement atoi to convert a string to an integer.Hint: Carefully consider all possible input cases. If you want a challenge, please do not see below and ask yourself what are the possible input ca原创 2014-10-15 21:27:12 · 699 阅读 · 0 评论 -
Scramble String (Java)
Given a string s1, we may represent it as a binary tree by partitioning it to two non-empty substrings recursively.Below is one possible representation of s1 = "great": great / \ gr原创 2015-02-04 22:22:32 · 443 阅读 · 0 评论 -
Letter Combinations of a Phone Number (Java)
Given a digit string, return all possible letter combinations that the number could represent.A mapping of digit to letters (just like on the telephone buttons) is given below.Input:Digit st原创 2015-01-19 16:09:57 · 349 阅读 · 0 评论 -
Palindrome Partitioning (Java)
Given a string s, partition s such that every substring of the partition is a palindrome.Return all possible palindrome partitioning of s.For example, given s = "aab",Return [ ["aa","原创 2015-01-19 16:41:52 · 358 阅读 · 0 评论 -
Add Binary (Java)
Given two binary strings, return their sum (also a binary string).For example,a = "11"b = "1"Return "100".Sourcepublic class Solution { public String addBinary(String a, St原创 2014-12-26 10:41:48 · 442 阅读 · 0 评论 -
Implement strStr() (Java)
Implement strStr().Returns a pointer to the first occurrence of needle in haystack, or null if needle is not part of haystack.注意 " "原创 2014-10-28 13:12:33 · 305 阅读 · 0 评论 -
Length of Last Word (Java)
Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.If the last word does not exist, return 0.Note: A word is原创 2014-10-28 21:52:20 · 356 阅读 · 0 评论 -
Compare Version Numbers (Java)
Compare two version numbers version1 and version1.If version1 > version2 return 1, if version1 version2 return -1, otherwise return 0.You may assume that the version strings are non-empty and co原创 2014-12-24 15:23:07 · 551 阅读 · 0 评论 -
Valid Palindrome (Java)
Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.For example,"A man, a plan, a canal: Panama" is a palindrome."race a car" is not a原创 2014-12-23 10:31:29 · 315 阅读 · 0 评论 -
Longest Common Prefix (Java)
Write a function to find the longest common prefix string amongst an array of strings.Source原创 2014-10-16 12:36:01 · 471 阅读 · 0 评论 -
Substring with Concatenation of All Words
You are given a string, S, and a list of words, L, that are all of the same length. Find all starting indices of substring(s) in S that is a concatenation of each word in L exactly once and without原创 2015-02-16 13:46:29 · 446 阅读 · 0 评论