随笔分类 - String
摘要:[抄题]: Given a non-empty string s and an abbreviation abbr, return whether the string matches with the given abbreviation. A string such as "word" cont
阅读全文
摘要:[抄题]: You are playing the following Flip Game with your friend: Given a string that contains only these two characters: + and -, you and your friend t
阅读全文
摘要:[抄题]: You are given a string representing an attendance record for a student. The record only contains the following three characters: A student could
阅读全文
摘要:[抄题]: X is a good number if after rotating each digit individually by 180 degrees, we get a valid number that is different from X. Each digit must be
阅读全文
摘要:[抄题]: 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 s
阅读全文
摘要:[抄题]: Given an array of characters, compress it in-place. The length after compression must always be smaller than or equal to the original array. Eve
阅读全文
摘要:[抄题]: 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
阅读全文
摘要:[抄题]: [暴力解法]: 时间分析: 空间分析: [优化后]: 时间分析: 空间分析: [奇葩输出条件]: [奇葩corner case]: [思维问题]: [一句话思路]: 两个单词的话,就是看谁长 [输入量]:空: 正常情况:特大:特小:程序里处理到的特殊情况:异常情况(不合法不合理的输入):
阅读全文
摘要:[抄题]: 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
阅读全文
摘要:[抄题]: Given two strings A and B, find the minimum number of times A has to be repeated such that B is a substring of it. If no such solution, return -
阅读全文
摘要:[抄题]: Give a string s, count the number of non-empty (contiguous) substrings that have the same number of 0's and 1's, and all the 0's and all the 1's
阅读全文
摘要:[抄题]: [暴力解法]: 时间分析: 空间分析: [优化后]: 时间分析: 空间分析: [奇葩输出条件]: [奇葩corner case]: 最后一位是空格,可能误判lastindexof()。所以必须用.trim() [思维问题]: [一句话思路]: 用函数 再次强调是最后一位的索引是lengt
阅读全文
摘要:[抄题]: Given a non-empty string s, you may delete at most one character. Judge whether you can make it a palindrome. Example 1: Example 2: [暴力解法]: 时间分析
阅读全文
摘要:[抄题]: Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases. For example,"A man, a plan, a cana
阅读全文
摘要:[抄题]: Write a function that takes a string as input and reverse only the vowels of a string. Example 1:Given s = "hello", return "holle". Example 2:Gi
阅读全文
摘要:[抄题]: Given an arbitrary ransom note string and another string containing letters from all the magazines, write a function that will return true if th
阅读全文
摘要:[抄题]: Given a string, you need to reverse the order of characters in each word within a sentence while still preserving whitespace and initial word or
阅读全文
摘要:[抄题]: Initially, there is a Robot at position (0, 0). Given a sequence of its moves, judge if this robot makes a circle, which means it moves back to
阅读全文
摘要:[抄题]: Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. The brackets must close i
阅读全文
摘要:[抄题]: Write a function to find the longest common prefix string amongst an array of strings. 在 "ABCD" "ABEF" 和 "ACEF" 中, LCP 为 "A" 在 "ABCDEFG", "ABCEF
阅读全文

浙公网安备 33010602011771号