问题:
此题java和其它的要求内存要求是一样的,弄了两遍都超时间。
发现一个专门对付杭电最后一个不要空格的方法,String输出:
s=s.substring(0,s.length()-1);去掉字符串最后一个字符。。
整除的尾数
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (J...
分类:
编程语言 时间:
2015-05-29 14:01:21
阅读次数:
139
public class Solution { public int longestConsecutive(int[] nums) { HashMap hs = new HashMap(); for (int i : nums) { hs.pu...
分类:
其他好文 时间:
2015-05-29 11:29:33
阅读次数:
109
public class Solution { public String longestCommonPrefix(String[] strs) { //http://www.cnblogs.com/springfor/p/3872316.html if(strs=...
分类:
其他好文 时间:
2015-05-29 09:47:20
阅读次数:
83
关键在于写好helperpublic class Solution { public String longestPalindrome(String s) { if(s==null) return null; if(s.length()==1) return s; ...
分类:
其他好文 时间:
2015-05-29 00:51:42
阅读次数:
149
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. Fo...
分类:
其他好文 时间:
2015-05-28 19:59:44
阅读次数:
129
写完之后看到网上很多人的做法是暴力匹配,其实不用这样的。
我们只要先将字符串排序,那么如果相邻的两个字符串一定前缀匹配度最高,那么我们只需要遍历一遍,每次比较当前字符串和它的前一个字符串的前缀,
得出len,然后取所有len中的最小值即可。
注意特判size为0和1的情况。时间8ms
class Solution {
public:
string longestCommonPref...
分类:
编程语言 时间:
2015-05-28 18:07:22
阅读次数:
182
字符串:stringLength - 字符串的长度。TrimStart()_TrimEnd()Trim()ToUpper()ToLower()Replace("要被替换的","要去替换的")返回替换后的字符串。Substring(起始位置)Substring(起始位置,截取的长度)IndexOf("...
分类:
其他好文 时间:
2015-05-28 12:22:24
阅读次数:
128
第三道题Longest
Substring Without Repeating Characters如下:
public class Solution {
public int lengthOfLongestSubstring(String s) {
HashMap hs = new HashMap();
int maxl = 0;...
分类:
编程语言 时间:
2015-05-28 08:15:38
阅读次数:
264
Given a string s, partition s such that every substring of the partition is a palindrome.
Return the minimum cuts needed for a palindrome partitioning of s.
For example, given s = "aab",
Return...
分类:
其他好文 时间:
2015-05-27 17:29:29
阅读次数:
130
public static string GetString(this HtmlHelper htmlHelper, string s, int l, string endStr)
{
string temp = s.Substring(0, (s.Length
byte[] encodedBytes = Encoding.A...
分类:
其他好文 时间:
2015-05-27 17:26:11
阅读次数:
146