网址:https://leetcode.com/problems/longest-palindromic-substring/
题意:
找出最长回文字符串.
解法1:
自然是暴力枚举,把每一个元素从中间往左右遍历,如果是且是最长的存下字符串.
比如abccba.
定位元素是2->c.
找左1->b.不行
找右3->c.可以->找左右同时->找左右同时
找左右同时.不行
思路就是...
分类:
其他好文 时间:
2015-04-28 22:56:08
阅读次数:
218
题意:给你n*m的矩阵,然后每行取一个元素,组成一个包含n个元素的序列,一共有n^m种序列,
让你求出序列和最小的前n个序列的序列和。
先介绍下堆的基本操作:
int arr[N];
make_heap(arr+1,arr+N);//对数组arr建堆,堆里第一个元素为最大值
pop_heap(arr+1,arr+N+1);//将第一个元素与最后一和元素交换
push_heap(ar...
分类:
其他好文 时间:
2015-04-28 22:55:15
阅读次数:
280
题意:
给n,m,k。
排列n~m之间的所有数。
保证相邻的2~k位之和均不为素数。
思路:
直接DFS。
代码:
#include"cstdlib"
#include"cstdio"
#include"cstring"
#include"cmath"
#include"queue"
#include"algorithm"
#include"iostream"
#include"...
分类:
其他好文 时间:
2015-04-28 22:56:01
阅读次数:
209
题目:
Determine whether an integer is a palindrome. Do this without extra space.
Some hints:
Could negative integers be palindromes? (ie, -1)
If you are thinking of converting the integer to s...
分类:
其他好文 时间:
2015-04-28 22:53:01
阅读次数:
177
给出6*6的矩阵,起点,终点,一共三堵墙,墙不会相交。
求起点到终点的最少步,保证有解
对每次移动判断相对应的是否有墙即可
#include "stdio.h"
#include "string.h"
#include "queue"
using namespace std;
const int dir[4][2]={ {1,0},{-1,0},{0,1},{0,-1} };
in...
分类:
其他好文 时间:
2015-04-28 22:52:43
阅读次数:
231
网址:https://leetcode.com/problems/zigzag-conversion/
题意:
转换一种编码格式?类似于这种意思吧...
反正挺无聊的一题...找规律...模拟题
分析:
特别注意以下numRows等于1和字符串长度小于numRows
解法:
按照行列来划分,常规的就是满列,
非常规的就是每隔(numRows)就存在的(多余)值
代码:
http...
分类:
其他好文 时间:
2015-04-28 22:53:50
阅读次数:
177
题意:
给一个n,有多少种连续的素数和加起来等于n。
思路:
打素数表,然后直接暴力。
代码:
#include"cstdlib"
#include"cstdio"
#include"cstring"
#include"cmath"
#include"queue"
#include"algorithm"
#include"iostream"
#include"map"
#include"...
分类:
其他好文 时间:
2015-04-28 22:54:18
阅读次数:
160
一个数如果恰好等于它的因子和,这个数就成为完数。
例如:6 = 1 + 2 + 3。再如 8 的因子和是7(即1 + 2 + 4),8不是完数。
编程找出1000以内的所有完数。...
分类:
其他好文 时间:
2015-04-28 22:51:46
阅读次数:
586
结构继承关系
-public static class AdapterContextMenuInfo extends Object implements ContextMenu.ContextMenuInfo-java.lang.Object
android.widget.AdapterView.AdapterContextMenuInfo类概述当显示 AdapterView 的上下文菜单时,为...
分类:
其他好文 时间:
2015-04-28 22:54:36
阅读次数:
335
串口是个好东西,前几篇裸奔程序由于没有串口,自己调试都是有led等来表示的,比较“苦逼”,终于可以用串口了~~~,这里主要采用上一篇博文(嵌入式学习笔记007-裸奔篇之定时器),也就是串口也是用中断实现的,而且也只是在前一篇博文增加串口的初始化uart0_init(),以及在中断处理函数增加对串口的处理。只要稍微改造前一篇博文就是一个通用的中断处理程序!
这里主要实现在串口输入一个字符,接受后+2再...
分类:
其他好文 时间:
2015-04-28 22:51:30
阅读次数:
476
Given preorder and inorder traversal of a tree, construct the binary tree.Note:
You may assume that duplicates do not exist in the tree....
分类:
其他好文 时间:
2015-04-28 22:52:42
阅读次数:
199
Next Permutation
Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.
If such arrangement is not possible, it must rearrange it ...
分类:
其他好文 时间:
2015-04-28 22:50:49
阅读次数:
222
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define INF 100000000
using namespace std;
int a[1005];
int b[1005];
int dp[1005][1005];
int mai...
分类:
其他好文 时间:
2015-04-28 22:52:11
阅读次数:
163
Hbase Client Test Case...
分类:
其他好文 时间:
2015-04-28 22:51:00
阅读次数:
193
ZOJ 3872 Beauty of Array(数学啊)...
分类:
其他好文 时间:
2015-04-28 22:49:36
阅读次数:
237
Description:
Count the number of prime numbers less than a non-negative number, n
提示晒数法:
http://en.wikipedia.org/wiki/Sieve_of_Eratosthenes
https://primes.utm.edu/howmany.html
别人的代码:
...
分类:
其他好文 时间:
2015-04-28 22:49:39
阅读次数:
238
原型模式是一种创建型设计模式,它通过复制一个已经存在的实例来返回新的实例,而不是新建实例。被复制的实例就是我们所称的原型,这个原型是可定制的。原型模式多用于创建复杂的或者耗时的实例, 因为这种情况下,复制一个已经存在的实例可以使程序运行更高效。...
分类:
其他好文 时间:
2015-04-28 22:51:35
阅读次数:
265