下午去蹭了一发新浪的笔试。炒鸡多的网络基础知识,总共18道题,就写了8道左右吧,剩下的全是网络知识,这部分抽时间至少过一过。其中一道算法题,回来跟嘟嘟商量,才发现是leetcode上的原题,连example都没有变,这可是道难度系数5的题,我嘞个去。题目:给定三个字符串s1,s2,s3,判断s3是否...
分类:
其他好文 时间:
2014-06-11 08:25:39
阅读次数:
241
题目:For example,"A man, a plan, a canal: Panama" is a palindrome. "race a car" is not a palindrome.
解题思路:验证一个字符串是否是回文字符串。首先看看wiki上对于回文的解释:回文,亦称回环,是正读反读都能读通的句子,亦有将文字排列成圆圈者,Famous examples include "Amore, Roma", "A man, a plan, a canal: Panama" and "No 'x' in...
分类:
其他好文 时间:
2014-06-08 16:30:29
阅读次数:
235
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...
分类:
其他好文 时间:
2014-06-08 16:27:47
阅读次数:
231
题目:For example, given s = "aab",
Return 1 since the palindrome partitioning ["aa","b"] could be produced using 1 cut
解题思路:给一个字符串,如果字符串可以划分成若干子回文字符串,返回最小的划分数量。
这个题如果还用之前求所有划分组合的循环加递归方法的话,就会得到超时的错误。这是就要考虑别的方法,动态规划倒是一个不错的方法,但是动态规划最重要的是要找到动态方程。本题的动态方程:
dp[i] =...
分类:
其他好文 时间:
2014-06-08 14:56:58
阅读次数:
257
题目
Given a string containing only digits, restore it by returning all possible valid IP address combinations.
For example:
Given "25525511135",
return ["255.255.11.135", "255.255.111.3...
分类:
其他好文 时间:
2014-06-08 10:37:47
阅读次数:
273
MainActivity如下:
package com.example.ttt;
import android.app.Activity;
import android.app.ProgressDialog;
import android.os.Bundle;
import android.view.Window;
/**
* Demo描述:
* 改变系统自带ProgressDialog的...
分类:
其他好文 时间:
2014-06-08 09:24:15
阅读次数:
190
题目
Given s1, s2, s3, find whether s3 is formed by the interleaving of s1 and s2.
For example,
Given:
s1 = "aabcc",
s2 = "dbbca",
When s3 = "aadbbcbcac", return true.
When s3 = "aadb...
分类:
其他好文 时间:
2014-06-08 09:14:26
阅读次数:
215
Given two integersnandk, return all possible
combinations ofknumbers out of 1 ...n.For example,Ifn= 4 andk= 2, a solution
is:[ [2,4], [3,4], [2,3],...
分类:
其他好文 时间:
2014-06-08 08:08:29
阅读次数:
294
Spiral MatrixGiven a matrix of m x n elements
(m rows, n columns), return all elements of the matrix in spiral order.For
example, Given the following ...
分类:
其他好文 时间:
2014-06-07 22:57:31
阅读次数:
236
Given a linked list, remove thenthnode from the
end of list and return its head.For example, Given linked list:
1->2->3->4->5, and n = 2. After re...
分类:
其他好文 时间:
2014-06-07 16:54:26
阅读次数:
221