随笔分类 -  String

摘要:[抄题]: We are given two strings, A and B. A shift on A consists of taking string A and moving the leftmost character to the rightmost position. For exa 阅读全文
posted @ 2018-08-10 22:07 苗妙苗 阅读(303) 评论(0) 推荐(0)
摘要:[抄题]: S and T are strings composed of lowercase letters. In S, no letter occurs more than once. S was sorted in some custom order previously. We want 阅读全文
posted @ 2018-08-04 23:14 苗妙苗 阅读(195) 评论(0) 推荐(0)
摘要:[抄题]: Compare two version numbers version1 and version2.If version1 > version2 return 1; if version1 < version2 return -1;otherwise return 0. You may 阅读全文
posted @ 2018-08-01 16:57 苗妙苗 阅读(172) 评论(0) 推荐(0)
摘要:[抄题]: Given an input string, reverse the string word by word. Example: [暴力解法]: 时间分析: 空间分析: [优化后]: 时间分析: 空间分析: [奇葩输出条件]: [奇葩corner case]: [思维问题]: 打碎成数组 阅读全文
posted @ 2018-07-31 14:52 苗妙苗 阅读(303) 评论(0) 推荐(0)
摘要:[抄题]: Given an input string , reverse the string word by word. Example: [暴力解法]: 时间分析: 空间分析: [优化后]: 时间分析: 空间分析: [奇葩输出条件]: [奇葩corner case]: [思维问题]: [英文数 阅读全文
posted @ 2018-07-30 22:58 苗妙苗 阅读(195) 评论(0) 推荐(0)
摘要:[抄题]: Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000. Example 1: Example 2: [暴力解法] 阅读全文
posted @ 2018-07-29 11:47 苗妙苗 阅读(146) 评论(0) 推荐(0)
摘要:[抄题]: Example 2: Example 3: Example 4: Example 5: [暴力解法]: 时间分析: 空间分析: [优化后]: 时间分析: 空间分析: [奇葩输出条件]: [奇葩corner case]: [思维问题]: 根本不知道应该怎么处理越界啊: 先设置一个bound 阅读全文
posted @ 2018-07-28 21:47 苗妙苗 阅读(111) 评论(0) 推荐(0)
摘要:计算机的基本任务之一。 举例来说,有一个字符串"BBC ABCDAB ABCDABCDABDE",我想知道,里面是否包含另一个字符串"ABCDABD"? 许多算法可以完成这个任务,Knuth-Morris-Pratt算法(简称KMP)是最常用的之一。它以三个发明者命名,起头的那个K就是著名科学家Do 阅读全文
posted @ 2018-07-07 09:50 苗妙苗 阅读(590) 评论(0) 推荐(0)
摘要:[抄题]: 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 re 阅读全文
posted @ 2018-06-05 22:50 苗妙苗 阅读(136) 评论(0) 推荐(0)
摘要:[抄题]: Given an array of words and a width maxWidth, format the text such that each line has exactly maxWidth characters and is fully (left and right) 阅读全文
posted @ 2018-05-25 17:19 苗妙苗 阅读(225) 评论(0) 推荐(0)
摘要:[抄题]: Convert a non-negative integer to its english words representation. Given input is guaranteed to be less than 231 - 1. Example 1: Example 2: Exa 阅读全文
posted @ 2018-05-20 21:39 苗妙苗 阅读(127) 评论(0) 推荐(0)
摘要:[抄题]: A sentence S is given, composed of words separated by spaces. Each word consists of lowercase and uppercase letters only. We would like to conve 阅读全文
posted @ 2018-04-30 22:39 苗妙苗 阅读(256) 评论(0) 推荐(0)
摘要:[抄题]: Given a paragraph and a list of banned words, return the most frequent word that is not in the list of banned words. It is guaranteed there is a 阅读全文
posted @ 2018-04-30 17:02 苗妙苗 阅读(235) 评论(0) 推荐(0)
摘要:[抄题]: Given a list of strings words representing an English Dictionary, find the longest word in words that can be built one character at a time by ot 阅读全文
posted @ 2018-04-27 09:09 苗妙苗 阅读(153) 评论(0) 推荐(0)
摘要:[抄题]: Given a string which consists of lowercase or uppercase letters, find the length of the longest palindromes that can be built with those letters 阅读全文
posted @ 2018-04-25 21:06 苗妙苗 阅读(105) 评论(0) 推荐(0)
摘要:[抄题]: Given a string, determine if a permutation of the string could form a palindrome. For example,"code" -> False, "aab" -> True, "carerac" -> True. 阅读全文
posted @ 2018-04-25 16:32 苗妙苗 阅读(81) 评论(0) 推荐(0)
摘要:[抄题]: Given two strings s and t which consist of only lowercase letters. String t is generated by random shuffling string s and then add one more lett 阅读全文
posted @ 2018-04-24 16:08 苗妙苗 阅读(223) 评论(0) 推荐(0)
摘要:[抄题]: Given a pattern and a string str, find if str follows the same pattern. Here follow means a full match, such that there is a bijection between a 阅读全文
posted @ 2018-04-24 10:49 苗妙苗 阅读(589) 评论(0) 推荐(0)
摘要:[抄题]: 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 阅读全文
posted @ 2018-04-23 21:12 苗妙苗 阅读(124) 评论(0) 推荐(0)
摘要:[抄题]: Given a string s and a list of strings dict, you need to add a closed pair of bold tag <b> and </b> to wrap the substrings in s that exist in di 阅读全文
posted @ 2018-03-27 14:55 苗妙苗 阅读(140) 评论(0) 推荐(0)