<?xml version="1.0" encoding="utf-8" ?><rss version="2.0"><channel><title><![CDATA[whatsname的Blog]]></title><description><![CDATA[]]></description><link>https://blog.csdn.net/whatsname</link><language>zh-cn</language><generator>https://blog.csdn.net/</generator><copyright><![CDATA[Copyright &copy; whatsname]]></copyright><item><title><![CDATA[Q35、（矩阵）]]></title><link>https://blog.csdn.net/whatsname/article/details/9048441</link><guid>https://blog.csdn.net/whatsname/article/details/9048441</guid><author>whatsname</author><pubDate>Fri, 07 Jun 2013 15:55:31 +0800</pubDate><description><![CDATA[求一个矩阵中最大的二维矩阵(元素和最大).如:
1 2 0 3 4
2 3 4 5 1
1 1 5 3 0
中最大的是:
4 5
5 3
要求:(1)写出算法;(2)分析时间复杂度;(3)用 C 写出关键代码


思路：
自己没想到好的方法..在网上找到的都是时间复杂度是O(m*n)的算法..也就是遍历整个矩阵..这个感觉有点小不爽..


public class Q]]></description><category></category></item><item><title><![CDATA[Q34、（队列）]]></title><link>https://blog.csdn.net/whatsname/article/details/9048329</link><guid>https://blog.csdn.net/whatsname/article/details/9048329</guid><author>whatsname</author><pubDate>Fri, 07 Jun 2013 15:49:06 +0800</pubDate><description><![CDATA[实现一个队列。
队列的应用场景为：
一个生产者线程将 int 类型的数入列，一个消费者线程将 int 类型的数出列


思路：
多线程...
public class Q34 {
	public static Queue queue = new LinkedList();
	public static void main(String[] args) throws Exception]]></description><category></category></item><item><title><![CDATA[Q33、（字符串）]]></title><link>https://blog.csdn.net/whatsname/article/details/9047877</link><guid>https://blog.csdn.net/whatsname/article/details/9047877</guid><author>whatsname</author><pubDate>Fri, 07 Jun 2013 15:37:20 +0800</pubDate><description><![CDATA[实现一个挺高级的字符匹配算法：
给一串很长字符串，要求找到符合要求的字符串，例如目的串：123
1******3***2 ,12*****3 这些都要找出来
其实就是类似一些和谐系统。。。。。


思路：
现在只有一个有问题的思想：
源串：21362
两个指针head和tail，head在后，tail在前
如果head~tail之间的子字符串包含这些和谐系统，比如head=0,]]></description><category></category></item><item><title><![CDATA[Q32、（数组、规划）]]></title><link>https://blog.csdn.net/whatsname/article/details/9045139</link><guid>https://blog.csdn.net/whatsname/article/details/9045139</guid><author>whatsname</author><pubDate>Fri, 07 Jun 2013 12:03:28 +0800</pubDate><description><![CDATA[有两个序列 a,b，大小都为 n,序列元素的值任意整数，无序；
要求：通过交换 a,b 中的元素，使[序列 a 元素的和]与[序列 b 元素的和]之间的差最小。
例如: 
var a=[100,99,98,1,2,3];
var b=[1,2,3,4,5,40];




思路：
假设序列a和b的和分别为sumA和sumB，假设sumA>sumB。
交换a中的x和b中的y，交]]></description><category></category></item><item><title><![CDATA[Q30、在从 1 到 n 的正数中 1 出现的次数（数组）]]></title><link>https://blog.csdn.net/whatsname/article/details/9045127</link><guid>https://blog.csdn.net/whatsname/article/details/9045127</guid><author>whatsname</author><pubDate>Fri, 07 Jun 2013 10:27:39 +0800</pubDate><description><![CDATA[题目：输入一个整数 n，求从 1 到 n 这 n 个整数的十进制表示中 1 出现的次数。
例如输入 12，从 1 到 12 这些整数中包含 1  的数字有 1， 10， 1 1 和 12， 1 一共出现了 5 次。


编程之美原题.....]]></description><category></category></item><item><title><![CDATA[Q29、栈的 push、pop 序列（栈）]]></title><link>https://blog.csdn.net/whatsname/article/details/9032649</link><guid>https://blog.csdn.net/whatsname/article/details/9032649</guid><author>whatsname</author><pubDate>Wed, 05 Jun 2013 18:14:04 +0800</pubDate><description><![CDATA[题目：输入两个整数序列。其中一个序列表示栈的 push 顺序，
判断另一个序列有没有可能是对应的 pop 顺序。
为了简单起见，我们假设 push 序列的任意两个整数都是不相等的。 
比如输入的 push 序列是 1、2、3、4、5，那么 4、5、3、2、1 就有可能是一个 pop 系列。
因为可以有如下的 push 和 pop 序列：
push 1，push 2，push 3，push]]></description><category></category></item><item><title><![CDATA[Q28、整数的二进制表示中 1 的个数（运算）]]></title><link>https://blog.csdn.net/whatsname/article/details/9028697</link><guid>https://blog.csdn.net/whatsname/article/details/9028697</guid><author>whatsname</author><pubDate>Wed, 05 Jun 2013 10:52:19 +0800</pubDate><description><![CDATA[题目：输入一个整数，求该整数的二进制表达中有多少个 1。
例如输入 10，由于其二进制表示为 1010，有两个 1，因此输出 2。


思路：
编程之美原题..
m&(m-1)，每次与操作都会消减二进制中的一个1。假设m=5，二进制表示为101
m&m-1:   101
       &100
=100


public class Q28 {
	public static]]></description><category></category></item><item><title><![CDATA[No27、跳台阶问题（递归）]]></title><link>https://blog.csdn.net/whatsname/article/details/8689290</link><guid>https://blog.csdn.net/whatsname/article/details/8689290</guid><author>whatsname</author><pubDate>Mon, 18 Mar 2013 22:04:01 +0800</pubDate><description><![CDATA[题目：一个台阶总共有n级，如果一次可以跳1级，也可以跳2级。 
求总共有多少总跳法，并分析算法的时间复杂度。 
这道题最近经常出现，包括MicroStrategy等比较重视算法的公司 
都曾先后选用过个这道题作为面试题或者笔试题。
 
解题思路：
 
经典的青蛙跳台阶.....第一次看到果断被干掉了....后来在网上看了一下..这尼玛就是斐波那契数列....疯了...
 
假设f]]></description><category></category></item><item><title><![CDATA[Q26、左旋转字符串（字符串）]]></title><link>https://blog.csdn.net/whatsname/article/details/8689206</link><guid>https://blog.csdn.net/whatsname/article/details/8689206</guid><author>whatsname</author><pubDate>Mon, 18 Mar 2013 21:53:41 +0800</pubDate><description><![CDATA[题目： 
定义字符串的左旋转操作：把字符串前面的若干个字符移动到字符串的尾部。 
如把字符串abcdef左旋转2位得到字符串cdefab。请实现字符串左旋转的函数。 
要求时间对长度为n的字符串操作的复杂度为O(n)，辅助内存为O(1)。
 
解题思路：
 
a b c d e f  左旋转两位
 
Step1: 前两位字符逆序，得到：
b a c d e f
Step2:]]></description><category></category></item><item><title><![CDATA[Q25、（字符串）]]></title><link>https://blog.csdn.net/whatsname/article/details/8689058</link><guid>https://blog.csdn.net/whatsname/article/details/8689058</guid><author>whatsname</author><pubDate>Mon, 18 Mar 2013 21:36:44 +0800</pubDate><description><![CDATA[写一个函数,它的原形是int continumax(char *outputstr,char *intputstr) 
功能： 
在字符串中找出连续最长的数字串，并把这个串的长度返回， 
并把这个最长数字串付给其中一个函数参数outputstr所指内存。 
例如："abcd12345ed125ss123456789"的首地址传给intputstr 后，函数将返回9， 

outputs]]></description><category></category></item><item><title><![CDATA[Q24、（链表）：链表操作，单链表就地逆置]]></title><link>https://blog.csdn.net/whatsname/article/details/8688736</link><guid>https://blog.csdn.net/whatsname/article/details/8688736</guid><author>whatsname</author><pubDate>Mon, 18 Mar 2013 20:07:17 +0800</pubDate><description><![CDATA[题目：
链表操作，单链表就地逆置
 
解题思路：

很经典的一个链表算法题..其实需要注意的就是在改变链表的时候一定要维持你需要的指针的相对位置...
其实挺简单的...
 
public class Q24 {
	public static void main(String[] args) {
		//建立链表
		Node head = new Node(1);]]></description><category></category></item><item><title><![CDATA[Q22、Q23]]></title><link>https://blog.csdn.net/whatsname/article/details/8684459</link><guid>https://blog.csdn.net/whatsname/article/details/8684459</guid><author>whatsname</author><pubDate>Sun, 17 Mar 2013 19:37:39 +0800</pubDate><description><![CDATA[Q22...智力题..过
Q23...没看懂啥意思...以后再看...]]></description><category></category></item><item><title><![CDATA[No21、（数组）]]></title><link>https://blog.csdn.net/whatsname/article/details/8675317</link><guid>https://blog.csdn.net/whatsname/article/details/8675317</guid><author>whatsname</author><pubDate>Thu, 14 Mar 2013 22:18:32 +0800</pubDate><description><![CDATA[2010年中兴面试题 
编程求解： 
输入两个整数  n 和  m，从数列1，2，3.......n 中  随意取几个数, 
使其和等于  m ,要求将其中所有的可能组合列出来. 
 
解题思路：
乍一看还是挺吓人的...仔细想一下，在任意一个组合中，数列中的每一个数字都只有两种情况，加入组合或者不加入组合..这样我们可以从第一个数字开始递归，第一个数字有两种情况，加入或不加入，然后根]]></description><category></category></item><item><title><![CDATA[No20、（字符串）]]></title><link>https://blog.csdn.net/whatsname/article/details/8672179</link><guid>https://blog.csdn.net/whatsname/article/details/8672179</guid><author>whatsname</author><pubDate>Thu, 14 Mar 2013 11:21:59 +0800</pubDate><description><![CDATA[题目：输入一个表示整数的字符串，把该字符串转换成整数并输出。
例如输入字符串"345"，则输出整数 345。


解题思路：


1>Java里面的Integer.parseInt，可以看看它对异常情况的处理


2>循环相乘
第一版代码：
public class Q20 {
	public static void main(String[] args) {
		Stri]]></description><category></category></item><item><title><![CDATA[No、18 （数组）：需要再看]]></title><link>https://blog.csdn.net/whatsname/article/details/8671664</link><guid>https://blog.csdn.net/whatsname/article/details/8671664</guid><author>whatsname</author><pubDate>Thu, 14 Mar 2013 10:51:57 +0800</pubDate><description><![CDATA[题目：n 个数字（0,1,…,n-1）形成一个圆圈，从数字 0 开始，
每次从这个圆圈中删除第 m 个数字（第一个为当前数字本身，第二个为当前数字的下一个
数字）。当一个数字删除后，从被删除数字的下一个继续删除第 m 个数字。
求出在这个圆圈中剩下的最后一个数字。


解题思路：
约瑟夫环....好像是研究怎么让非基督徒跳海的方法...


1>一个长度为n的数组，初始化为0。]]></description><category></category></item><item><title><![CDATA[No17、题目：在一个字符串中找到第一个只出现一次的字符。如输入 abaccdeff，则输出 b。]]></title><link>https://blog.csdn.net/whatsname/article/details/8668394</link><guid>https://blog.csdn.net/whatsname/article/details/8668394</guid><author>whatsname</author><pubDate>Wed, 13 Mar 2013 15:46:48 +0800</pubDate><description><![CDATA[题目：在一个字符串中找到第一个只出现一次的字符。如输入 abaccdeff，则输出 b。
分析：这道题是 2006 年 google 的一道笔试题。


解题思路：
题目强调了两点：第一、需要记录字符出现的个数....第二、需要记录字符出现的次序..
两个长度为24的数组一个存储出现的顺序，一个存储字符出现的个数..
记录字符出现顺序的数组索引为顺序，存储的数据是字符-'a'；
记]]></description><category></category></item><item><title><![CDATA[Np16、输入一颗二元树，从上往下按层打印树的每个结点，同一层中按照从左往右的顺序打印。]]></title><link>https://blog.csdn.net/whatsname/article/details/8667207</link><guid>https://blog.csdn.net/whatsname/article/details/8667207</guid><author>whatsname</author><pubDate>Wed, 13 Mar 2013 11:09:04 +0800</pubDate><description><![CDATA[题目（微软）：
输入一颗二元树，从上往下按层打印树的每个结点，同一层中按照从左往右的顺序打印。 
例如输入
     8
    /   \
  6    10
 / \     /  \
5 7  9  11
输出 8 6 10 5 7 9 11。


解题思路：
编程之美3-10...分层遍历二叉树
思想很简单...一个队列，先将根节点入队....然后开始循环
当一]]></description><category></category></item><item><title><![CDATA[No15、输入一颗二元查找树，将该树转换为它的镜像]]></title><link>https://blog.csdn.net/whatsname/article/details/8667122</link><guid>https://blog.csdn.net/whatsname/article/details/8667122</guid><author>whatsname</author><pubDate>Wed, 13 Mar 2013 10:46:37 +0800</pubDate><description><![CDATA[题目：输入一颗二元查找树，将该树转换为它的镜像，
即在转换后的二元查找树中，左子树的结点都大于右子树的结点。
用递归和循环两种方法完成树的镜像转换。 
例如输入：
      8
     /   \
   6    10
  /  \     /  \
5   7 9   11
输出：
      8
     /    \
  10    6
  /  \    /]]></description><category></category></item><item><title><![CDATA[No14、（数组）]]></title><link>https://blog.csdn.net/whatsname/article/details/8666880</link><guid>https://blog.csdn.net/whatsname/article/details/8666880</guid><author>whatsname</author><pubDate>Wed, 13 Mar 2013 10:20:37 +0800</pubDate><description><![CDATA[题目：输入一个已经按升序排序过的数组和一个数字，
在数组中查找两个数，使得它们的和正好是输入的那个数字。
要求时间复杂度是 O(n)。如果有多对数字的和等于输入的数字，输出任意一对即可。
例如输入数组 1、2、4、7、11、15 和数字 15。由于 4+11=15，因此输出 4 和 11。


解题思路：
1>取出数组中的所有两个数的组合，求和比较，时间复杂度为O(n*n)
for]]></description><category></category></item><item><title><![CDATA[No13、（链表）]]></title><link>https://blog.csdn.net/whatsname/article/details/8666799</link><guid>https://blog.csdn.net/whatsname/article/details/8666799</guid><author>whatsname</author><pubDate>Wed, 13 Mar 2013 10:02:17 +0800</pubDate><description><![CDATA[题目：输入一个单向链表，输出该链表中倒数第 k 个结点。链表的倒数第 0 个结点为链表的尾指针。


解题思路：


1>遍历链表的长度为len，那么倒数第k个节点就是正数的第len-k+1个节点..再遍历一遍即可
时间复杂度是O(len)


2>两个指针p1,p2，p1指向头结点，p2向后移动k个位置，指向正数第k个位置；然后p1、p2同时向后移动，当p2到达最后一个节点，]]></description><category></category></item></channel></rss>