String
yuanhisn
这个作者很懒,什么都没留下…
展开
-
LeetCode 14 - Longest Common Prefix
Write a function to find the longest common prefix string amongst an array of strings. Solution 1: 比较每个字符串的第一个字符,然后第二个。。。。出现不同的字符的话,马上返回结果,如果所有字符串的第i个字符都相等,则把这个字符append到结果上去。 public String longes...原创 2015-03-04 13:35:21 · 54 阅读 · 0 评论 -
LeetCode 159 - Longest Substring with At Most Two Distinct Characters
Given a string S, find the length of the longest substring T that contains at most two distinct characters.For example,Given S = “eceba”,T is “ece” which its length is 3. [分析]brute force的解法就是构造出来所有...原创 2015-03-09 10:44:40 · 63 阅读 · 0 评论 -
LeetCode 68 - 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-03-12 05:14:12 · 136 阅读 · 0 评论 -
LeetCode 3 - 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-03-28 07:33:39 · 45 阅读 · 0 评论 -
LeetCode 6 - 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-05-03 12:26:07 · 42 阅读 · 0 评论 -
LeetCode 242 - Valid Anagram
Given two strings s and t, write a function to determine if t is an anagram of s. For example,s = "anagram", t = "nagaram", return true.s = "rat", t = "car", return false. Note:You may assume the s...原创 2015-08-03 23:05:16 · 83 阅读 · 0 评论 -
LeetCode 126 - Word Ladder II
Given two words (start and end), and a dictionary, find all shortest transformation sequence(s) from start to end, such that: Only one letter can be changed at a time Each intermediate word must ...原创 2015-03-02 08:12:17 · 47 阅读 · 0 评论 -
LeetCode 127 - Word Ladder
Given two words (start and end), and a dictionary, find the length of shortest transformation sequence from start to end, such that: Only one letter can be changed at a time Each intermediate wor...原创 2015-03-02 06:51:01 · 44 阅读 · 0 评论 -
first non-repeating character in a string
Given a string, find the first non-repeating character in it. For example, if the input string is “GeeksforGeeks”, then output should be ‘f’ and if input string is “GeeksQuiz”, then output should be...原创 2015-02-14 03:23:08 · 166 阅读 · 0 评论 -
LeetCode 44 - Wildcard Matching
Implement wildcard pattern matching with support for '?' and '*'. '?' Matches any single character. '*' Matches any sequence of characters (including the empty sequence). The matching should cov...原创 2015-02-14 23:57:06 · 45 阅读 · 0 评论 -
LeetCode 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 stri...原创 2015-02-15 01:28:22 · 48 阅读 · 0 评论 -
LeetCode 187 - Repeated DNA Sequences
All DNA is composed of a series of nucleotides abbreviated as A, C, G, and T, for example: "ACGAATTCCG". When studying DNA, it is sometimes useful to identify repeated sequences within the DNA. Wri...原创 2015-02-15 06:28:46 · 72 阅读 · 0 评论 -
LeetCode 151 - Reverse Words in a String
Given an input string, reverse the string word by word. For example,Given s = "the sky is blue",return "blue is sky the". Update (2015-02-12):For C programmers: Try to solve it in-place in O(1) sp...原创 2015-02-24 02:00:28 · 54 阅读 · 0 评论 -
LeetCode 186 - Reverse Words in a String II
跟Reverse Words in a String很类似,但是这里要求in-place,也就是说不需要开辟额外空间。 [分析]该题在LeetCode中假设开头和结尾没有空格,而且单词之间只有一个空格。但其实不需要这些假设也是可以的,就是代码会比较复杂。思路就是两步走,第一步就是将整个字符串翻转。然后从头逐步扫描,将每个遇到单词再翻转过来。 [注意事项]1)如果是Java,应该跟面试官指出...原创 2015-02-24 02:01:36 · 42 阅读 · 0 评论 -
[待续]Convert string to palindrome string with minimum insertions
Given a string, find the minimum number of characters to be inserted to convert it to palindrome. For Eg :- ab: Number of insertions required is 1. bab aa: N...原创 2015-02-26 05:47:17 · 184 阅读 · 0 评论 -
[待续]Minimum appends to convert string into palindrome
Convert the given string into palindrome with minimum number of appends(at end of the given string). O(n) algorithm will be appreciated.Input:MalayalOutput:Malayalam See discussions here at Linkedi...原创 2015-02-28 15:12:33 · 163 阅读 · 0 评论 -
Linkedin Interview - Isomorphic Strings
Given two strings, determine if they are isomorphic. Two words are called isomorphic if the letters in one word can be remapped to get the second word. Remapping a letter means replacing all occurren...原创 2015-08-03 23:10:49 · 74 阅读 · 0 评论