
String
文章平均质量分 72
zshouyi
这个作者很懒,什么都没留下…
展开
-
125. Valid Palindrome
[ 问题: ]Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.直译:给你一个字符串, 判定它是否是回文(只统计字母、数字,其他字符请忽略)。For example,"A man, a plan, a c原创 2016-12-24 03:52:57 · 319 阅读 · 0 评论 -
91. Decode Ways
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原创 2017-04-20 05:57:59 · 435 阅读 · 0 评论 -
22. Generate Parentheses
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:[ "((()))", "(()())", "(())()", "()(())原创 2017-04-20 11:40:21 · 342 阅读 · 0 评论 -
551. Student Attendance Record I
You are given a string representing an attendance record for a student. The record only contains the following three characters:'A' : Absent. 'L' : Late.'P' : Present. A student could原创 2017-05-03 12:25:15 · 381 阅读 · 0 评论 -
556. Next Greater Element III
Given a positive 32-bit integer n, you need to find the smallest 32-bit integer which has exactly the same digits existing in the integer n and is greater in value than n. If no such positive 32-bit原创 2017-05-04 11:48:22 · 579 阅读 · 0 评论 -
521. Longest Uncommon Subsequence I
Given a group of two strings, you need to find the longest uncommon subsequence of this group of two strings. The longest uncommon subsequence is defined as the longest subsequence of one of these str原创 2017-05-04 12:14:19 · 1029 阅读 · 0 评论 -
522. Longest Uncommon Subsequence II
Given a list of strings, you need to find the longest uncommon subsequence among them. The longest uncommon subsequence is defined as the longest subsequence of one of these strings and this subsequen原创 2017-05-06 01:21:00 · 2122 阅读 · 0 评论 -
555. Split Concatenated Strings
Given a list of strings, you could concatenate these strings together into a loop, where for each string you could choose to reverse it or not. Among all the possible loops, you need to find the lexic原创 2017-05-06 02:35:43 · 1424 阅读 · 0 评论 -
553. Optimal Division
Given a list of positive integers, the adjacent integers will perform the float division. For example, [2,3,4] -> 2 / 3 / 4.However, you can add any number of parenthesis at any position to change原创 2017-05-06 04:52:23 · 570 阅读 · 0 评论 -
544. Output Contest Matches
During the NBA playoffs, we always arrange the rather strong team to play with the rather weak team, like make the rank 1 team play with the rank nth team, which is a good strategy to make the conte原创 2017-05-06 09:54:16 · 518 阅读 · 0 评论 -
539. Minimum Time Difference
Given a list of 24-hour clock time points in "Hour:Minutes" format, find the minimum minutes difference between any two time points in the list. Example 1:Input: ["23:59","00:00"]Output: 1原创 2017-05-06 11:18:05 · 555 阅读 · 0 评论 -
536. Construct Binary Tree from String
You need to construct a binary tree from a string consisting of parenthesis and integers. The whole input represents a binary tree. It contains an integer followed by zero, one or two pairs of par原创 2017-05-06 12:07:10 · 840 阅读 · 0 评论 -
71. Simplify Path
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原创 2017-04-26 05:08:05 · 342 阅读 · 0 评论 -
93. Restore IP Addresses
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"]. (Orde原创 2017-04-26 05:44:04 · 372 阅读 · 0 评论 -
227. Basic Calculator II
Implement a basic calculator to evaluate a simple expression string.The expression string contains only non-negative integers, +, -, *, / operators and empty spaces . The integer division should原创 2017-04-27 08:12:29 · 331 阅读 · 0 评论 -
161. One Edit Distance
Given two strings S and T, determine if they are both one edit distance apart.所谓one edit distance是指只改变一个字母,更改、删除或者增加。解题思路从前向后遍历,遇到不同的字符,就对比之后的子字符串是否相同,相同说明只有这一处不同,不同则说明至少有两处,不符合题意。代码如下:public cl原创 2017-04-27 11:11:32 · 397 阅读 · 0 评论 -
385. Mini Parser
Given a nested list of integers represented as a string, implement a parser to deserialize it.Each element is either an integer, or a list -- whose elements may also be integers or other lists.原创 2017-04-27 12:48:05 · 243 阅读 · 0 评论 -
541. Reverse String II
Given a string and an integer k, you need to reverse the first k characters for every 2k characters counting from the start of the string. If there are less than k characters left, reverse all of th原创 2017-04-30 10:24:25 · 277 阅读 · 0 评论 -
557. Reverse Words in a String III
Given a string, you need to reverse the order of characters in each word within a sentence while still preserving whitespace and initial word order.Example 1:Input: "Let's take LeetCode contes原创 2017-04-30 09:57:42 · 307 阅读 · 0 评论 -
520. Detect Capital
Given a word, you need to judge whether the usage of capitals in it is right or not.We define the usage of capitals in a word to be right when one of the following cases holds:All letters in t原创 2017-04-30 07:50:47 · 361 阅读 · 0 评论 -
165. Compare Version Numbers
Compare two version numbers version1 and version2.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原创 2016-12-24 05:55:14 · 344 阅读 · 0 评论 -
157. Read N Characters Given Read4
The API: int read4(char *buf) reads 4 characters at a time from a file.The return value is the actual number of characters read. For example, it returns 3 if there is only 3 characters left in the原创 2016-12-25 08:28:43 · 480 阅读 · 0 评论 -
459. Repeated Substring Pattern
Given a non-empty string check if it can be constructed by taking a substring of it and appending multiple copies of the substring together. You may assume the given string consists of lowercase Engli原创 2016-12-26 13:25:10 · 474 阅读 · 0 评论 -
434. Number of Segments in a String
Count the number of segments in a string, where a segment is defined to be a contiguous sequence of non-space characters.Please note that the string does not contain any non-printable characters.原创 2016-12-26 14:55:07 · 338 阅读 · 0 评论 -
76. Minimum Window Substring
Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n).For example,S = "ADOBECODEBANC"T = "ABC"Minimum window is "BAN原创 2017-01-08 09:39:29 · 295 阅读 · 0 评论 -
438. Find All Anagrams in a String
Given a string s and a non-empty string p, find all the start indices of p's anagrams in s.Strings consists of lowercase English letters only and the length of both strings s and p will not be lar原创 2017-01-08 15:58:25 · 337 阅读 · 0 评论 -
249. Group Shifted Strings
Given a string, we can "shift" each of its letter to its successive letter, for example: "abc" -> "bcd". We can keep "shifting" which forms the sequence:"abc" -> "bcd" -> ... -> "xyz"Given a l原创 2017-01-09 07:28:11 · 342 阅读 · 0 评论 -
58. Length of Last Word
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原创 2016-12-24 09:01:00 · 373 阅读 · 0 评论 -
49. Group Anagrams
Given an array of strings, group anagrams together.For example, given: ["eat", "tea", "tan", "ate", "nat", "bat"], Return:[ ["ate", "eat","tea"], ["nat","tan"], ["bat"]]Note: Al原创 2017-03-06 10:36:39 · 214 阅读 · 0 评论 -
43. Multiply Strings
Given two non-negative integers num1 and num2 represented as strings, return the product of num1 and num2.Note:The length of both num1 and num2 is Both num1 and num2 contains only digits原创 2017-03-21 07:59:39 · 230 阅读 · 0 评论 -
17. Letter Combinations of a Phone Number
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原创 2017-04-11 05:34:20 · 689 阅读 · 0 评论 -
537. Complex Number Multiplication
Given two strings representing two complex numbers.You need to return a string representing their multiplication. Note i2 = -1 according to the definition.Example 1:Input: "1+1i", "1+1i"O原创 2017-04-02 03:30:22 · 975 阅读 · 0 评论 -
412. Fizz Buzz
Write a program that outputs the string representation of numbers from 1 to n.But for multiples of three it should output “Fizz” instead of the number and for the multiples of five output “Buzz”.原创 2017-04-04 10:29:16 · 326 阅读 · 0 评论 -
293. Flip Game
You are playing the following Flip Game with your friend: Given a string that contains only these two characters: + and -, you and your friend take turns to flip two consecutive "++" into "--". Th原创 2017-04-28 07:42:02 · 352 阅读 · 0 评论 -
468. Validate IP Address
Write a function to check whether an input string is a valid IPv4 address or IPv6 address or neither.IPv4 addresses are canonically represented in dot-decimal notation, which consists of four deci原创 2017-04-29 01:46:58 · 314 阅读 · 0 评论 -
408. Valid Word Abbreviation
Given a non-empty string s and an abbreviation abbr, return whether the string matches with the given abbreviation.A string such as "word" contains only the following valid abbreviations:["wor原创 2017-04-30 03:03:36 · 369 阅读 · 0 评论 -
271. Encode and Decode Strings
Design an algorithm to encode a list of strings to a string. The encoded string is then sent over the network and is decoded back to the original list of strings.Machine 1 (sender) has the functio原创 2017-04-27 14:13:21 · 522 阅读 · 0 评论