一、收获 1.层序输出二叉树,需要一个队列作为中转,如图(将就),以及queue模板的使用 2.C++,当变量不好用时,可以考虑全局变量,虽然不太好,但是对于一个算法无妨 eg: const int MAX=1000;int arr[MAX][4]={0};int n=0;int dlmNum=1; ...
分类:
其他好文 时间:
2019-02-25 09:21:08
阅读次数:
195
说明: ? 假设我们的环境只能存储 32 位大小的有符号整数,那么其数值范围为?[?231, 231?? 1]。如果数值超过这个范围,qing返回 INT_MAX (231?? 1) 或?INT_MIN (?231) 。 示例 1: 示例 2: 示例 3: 示例 4: 示例 5: 使用python3 ...
分类:
其他好文 时间:
2019-02-21 00:01:38
阅读次数:
174
队列:队列其实就是我们生活中的排队现象,先进入的先出,后进入的后出,代码实现如下: public class Queue<E> { private int front;//队头一端,只允许删除 private int rear;//队尾一端,只允许插入操作 private int max_size ...
分类:
编程语言 时间:
2019-02-19 00:45:43
阅读次数:
172
#include using namespace std; #define N 60 int n; int mp[N][N]; int ans; int alt[N][N]; int Max[N]; bool dfs(int cur,int tot)//cur是s1集合的个数 { if(0==cur... ...
分类:
其他好文 时间:
2019-02-16 15:06:55
阅读次数:
142
1、模板 1 #include<bits/stdc++.h> 2 using namespace std; 3 const int MAX=21000020; 4 char s[MAX],t[MAX<<1]; 5 int p[MAX<<1],cnt=0,mid,mr; 6 void manachar ...
分类:
其他好文 时间:
2019-02-16 13:18:38
阅读次数:
145
Difficulty: Medium Problem Given an array , we can perform a pancake flip : We choose some positive integer `k PancakeSort(int[] A) { int max = A.Leng ...
分类:
其他好文 时间:
2019-02-14 23:57:08
阅读次数:
329
Given an array of n positive integers and a positive integer s, find the minimal length of a contiguoussubarray of which the sum ≥ s. If there isn't o ...
分类:
编程语言 时间:
2019-02-10 12:29:27
阅读次数:
207
``` class ArrayDome { public static void main(String[] args) { int[] arr = {-12,-51,-12,-11}; int max = getMax(arr); int max_2 = getMax_2(arr); System... ...
分类:
编程语言 时间:
2019-02-09 12:01:19
阅读次数:
231
int n; int d[MAX_N + 1][MAX_N + 1]; void Floyd() { for(register int k = 1; k <= n; ++k) { for(register int i = 1; i <= n; ++i) { for(register int j = ... ...
分类:
其他好文 时间:
2019-02-06 10:43:11
阅读次数:
200
[toc] 题目链接 "Maximum Subarray LeetCode" 注意点 最大值有可能是正负数交替着出现 解法 解法一:一次遍历即可。当sum小于0的时候就重新开始求和,因为sum小于0再加上一个数字绝对不可能是max(即sum+nums[i] & nums) { int max = n ...
分类:
其他好文 时间:
2019-02-05 10:38:40
阅读次数:
198