
String
iteye_17352
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
Leetcode - Longest Palindrome Substring
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. [balabala] Method1从小到大...原创 2015-06-11 09:48:56 · 109 阅读 · 0 评论 -
Leetcode - Valid Number
Validate if a given string is numeric. Some examples: "0" => true " 0.1 " => true "abc" => false "1 a" => false "2e10" => true Note: It is intended for the problem statement to be am原创 2015-06-21 10:42:28 · 88 阅读 · 0 评论 -
Leetcode - Text Justification
Given an array of words and a length L, format the text such that each line has exactly L characters and is fully (left and right) justified. You should pack your words in a greedy approach; that i...原创 2015-06-22 18:29:38 · 102 阅读 · 0 评论 -
Leetcode - Strobogrammatic Number
A strobogrammatic number is a number that looks the same when rotated 180 degrees (looked at upside down). Write a function to determine if a number is strobogrammatic. The number is represented as...原创 2015-08-22 10:48:09 · 135 阅读 · 0 评论 -
Leetcode - Group Shifted String
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" -> ... -> &q原创 2015-08-22 16:20:31 · 138 阅读 · 0 评论 -
Leetcode - Isomorphic Strings
[分析] 思路1:维护两个哈希表,char[] map, boolean[] used, 长度均为256,map[charS] = charT, 表示将字符charS 映射为charT, used[charT]==true 表示charT已经被某个字符映射过了。同步遍历字符串s & t,记两者当前的字符分别为charS, charT, 若charS是新字符,且charT没有被使用,则我们可将其同...原创 2015-08-23 09:51:03 · 84 阅读 · 0 评论 -
Leetcode - One Edit Distance
[分析] 两字符串相同或者长度差异大于等于2都不符合要求,只需要检查那些长度相同或者相差为1的情况。逐个字符检查,发现第一个差异字符,若s和t长度相等将s中字符替换为t中字符,若不等则在s中插入t当前字符,然后跳出检查循环。若检查过程无差异字符(说明长度差1)或者消除发现的第一个差异后两字符串相等说明两字符串编辑距离为1. 这个思路和实现参考[url]https://leetcode.com/...原创 2015-08-27 20:26:17 · 99 阅读 · 0 评论 -
Leetcode - 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...原创 2015-08-27 20:56:29 · 131 阅读 · 0 评论 -
Leetcode - Read N Characters Given Read4 II - Call Multiple Times
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...原创 2015-08-28 09:00:18 · 115 阅读 · 0 评论 -
Leetcode - Substring with Contentaion of All Words
You are given a string, s, and a list of words, words, that are all of the same length. Find all starting indices of substring(s) in s that is a concatenation of each word in words exactly once and wi...原创 2015-06-18 10:01:33 · 94 阅读 · 0 评论 -
Leetcode - Simplify Path
Given an absolute path for a file (Unix-style), simplify it. For example, path = "/home/", => "/home" path = "/a/./b/../../c/", => "/c" [分析] 思路很简单,遇到“.”跳过,遇到“..”删除其前面一级目录,使用堆栈来删除前一级目录的想法很妙(要是我...原创 2015-06-17 21:58:55 · 94 阅读 · 0 评论 -
Leetcode - Shortest Palindrome
Given a string S, you are allowed to convert it to a palindrome by adding characters [color=red]in front of[/color] it. Find and return the shortest palindrome you can find by performing this transfor...原创 2015-06-13 10:55:43 · 118 阅读 · 0 评论 -
Leetcode - 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...原创 2015-06-13 16:36:41 · 92 阅读 · 0 评论 -
Leetcode - Add Binary
Given two binary strings, return their sum (also a binary string). For example,a = "11"b = "1"Return "100". public String addBinary(String a, String b) { if (a == null && b ...原创 2015-06-13 17:34:04 · 73 阅读 · 0 评论 -
Leetcode - Implement strStr()
Implement strStr(). Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack. [分析] 经典的字符查找问题,有四种经典解法, 暴力法,hash法,Boyer-Moorer算法和KMP算法。leetcode上分析指出...原创 2015-06-13 19:54:26 · 110 阅读 · 0 评论 -
Leetcode - Longest Substring Without Repeating Characters
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. For ...原创 2015-06-14 15:34:19 · 104 阅读 · 0 评论 -
Leetcode - Minimum Window String
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 "BANC". ...原创 2015-06-14 19:33:23 · 113 阅读 · 0 评论 -
Leetcode - Multiply String
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. [分析] Naive的做法是模拟笔算乘法操作,从高位到低位的顺序将num2...原创 2015-06-15 09:39:35 · 100 阅读 · 0 评论 -
Leetcode - ZigZag Conversion
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 N A P L S I...原创 2015-06-15 21:31:06 · 90 阅读 · 0 评论 -
Leetcode - Integer to English Words
[分析] 这题通过率之所以非常低是因为有很多corner case,代码写得不好时就很容易在各种corner case上刷跟头,第二十遍才被Accept,自己还真是有耐心。然后看到讨论区中的解答,一对比,差距啊,努力努力再努力! 注意:不需要添加“and” 大神漂亮的作品: [url]https://leetcode.com/discuss/55462/my-clean-java-solu...原创 2015-09-04 20:53:16 · 110 阅读 · 0 评论