随笔分类 - 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
阅读全文
摘要:[抄题]: 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
阅读全文
摘要:[抄题]: Compare two version numbers version1 and version2.If version1 > version2 return 1; if version1 < version2 return -1;otherwise return 0. You may
阅读全文
摘要:[抄题]: Given an input string, reverse the string word by word. Example: [暴力解法]: 时间分析: 空间分析: [优化后]: 时间分析: 空间分析: [奇葩输出条件]: [奇葩corner case]: [思维问题]: 打碎成数组
阅读全文
摘要:[抄题]: Given an input string , reverse the string word by word. Example: [暴力解法]: 时间分析: 空间分析: [优化后]: 时间分析: 空间分析: [奇葩输出条件]: [奇葩corner case]: [思维问题]: [英文数
阅读全文
摘要:[抄题]: 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: [暴力解法]
阅读全文
摘要:[抄题]: Example 2: Example 3: Example 4: Example 5: [暴力解法]: 时间分析: 空间分析: [优化后]: 时间分析: 空间分析: [奇葩输出条件]: [奇葩corner case]: [思维问题]: 根本不知道应该怎么处理越界啊: 先设置一个bound
阅读全文
摘要:计算机的基本任务之一。 举例来说,有一个字符串"BBC ABCDAB ABCDABCDABDE",我想知道,里面是否包含另一个字符串"ABCDABD"? 许多算法可以完成这个任务,Knuth-Morris-Pratt算法(简称KMP)是最常用的之一。它以三个发明者命名,起头的那个K就是著名科学家Do
阅读全文
摘要:[抄题]: 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
阅读全文
摘要:[抄题]: 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)
阅读全文
摘要:[抄题]: 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
阅读全文
摘要:[抄题]: 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
阅读全文
摘要:[抄题]: 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
阅读全文
摘要:[抄题]: 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
阅读全文
摘要:[抄题]: Given a string which consists of lowercase or uppercase letters, find the length of the longest palindromes that can be built with those letters
阅读全文
摘要:[抄题]: Given a string, determine if a permutation of the string could form a palindrome. For example,"code" -> False, "aab" -> True, "carerac" -> True.
阅读全文
摘要:[抄题]: 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
阅读全文
摘要:[抄题]: 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
阅读全文
摘要:[抄题]: 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
阅读全文
摘要:[抄题]: 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
阅读全文

浙公网安备 33010602011771号