1. This moment will nap, you will have a dream; But this moment study, you&nb...
#include <iostream>
using namespace std;
struct node{
char data;
struct node*left;
&...
P1081 猴子报数
数组实现方法:
for(int i=0;i<n;i++) { //n只猴子退圈
in...
P1151
方法1.重写Comparator中的compare方法
o1-o2 升序
o2-o1降序
Collections.sort(student, new Comparator() {
@Override
public int compar...
P1476
键值对的应用
Map<String, String> stuMap=new HashMap<String, String>(n);
stuMap.put(sno, stufo);//sno代表关键字,stufo代表值(值中信息包...
JAVA中String类提供了转大写的方法toUpperCase()和转小写的方法toLowerCase()
使用如下:
String a = "ABC";
system.out.pr...
1240 首字母大写
输入:
if so, you already have a google account. you can sign in on the right.
输出:
If So, You Already Have A Google Account....
题目ID:1654
#include<iostream>
#include<cstring>
using namespace std;
/*
思路:把二叉树当成满二叉树来存储;
较大位置的结点往上回溯,直到二者相遇,每一次回溯,路...
by 老猫
#include <iostream>
#include <string>
#include <string.h>
using namespace std;
void postorder(string preor...
创建二叉树时,要把左右孩子的指针指向NULL,以防止样例出现野指针,从而运行错误;
#include<iostream>
using namespace std;
typedef struct node
{
char data;...
#include<iostream>
#include<queue>
#include<string>
#include<stdio.h>
#include<cstring>
using namespace std;...
23
动态规划
1.最大连续子序列和
dp[i]表示以a[i]结尾的最大子序列和,
思路:dp[i]=max{dp[i-1]+a[i],a[i]}
在求dp[i]中最大值dp[k],则为最大连续子序列和
2.
题目描述
假设你有一个数组,其中第 i 个元素是股票在第 i 天的价格。
你有一次买入和卖出的机会。(只有买入了股票以后才能卖出)。请你设计一个算法来计算可以获得的最大收益。
输入 [1,4,2,2]
输出 3
思路:
当...
String s=sc.nextLine();
String[] str=s.split(" ");
int []prices=new int[str...
本博客是本人自己整理在刷题时候遇到的有用的或者有趣的代码,从2021.1.26开始整理,时间跨度较长,水平有限,还请见谅。
目录
求一段数字的长度。
统计整数中指定数字的个数。
求形如“aaaa……aaa”(n个a)...