这个题很简单,而且没什么条件限制,实际上应该加上复杂度等限制的。 一个有趣的解法就是投票 func majorityElement(nums []int) int { kv := make(map[int]int) max := 0 res := 0 for _, v := range nums { ...
分类:
其他好文 时间:
2020-03-14 00:51:18
阅读次数:
56
#include<iostream> #include<string> using namespace std; const int Max = 550; int Compare(int a[], int b[]); void Plus(int a[], int b[], int n); void ...
分类:
其他好文 时间:
2020-03-09 18:21:30
阅读次数:
73
#include<iostream> #include<string> using namespace std; const int Max = 20000; int Compare(int a[], int b[]); //比较大小 void Subtract(int a[], int b[]); ...
分类:
其他好文 时间:
2020-03-09 18:06:28
阅读次数:
65
#include<iostream> #include<string> using namespace std; const int Max = 550; void Enlarge(int p[], int q[], int bits); //将数组p的数字串右移bits位 int Compare( ...
分类:
其他好文 时间:
2020-03-09 17:56:50
阅读次数:
52
双端队列 实际上就是一个每次push pop的常规queue和另一个首位是最大值的queue type MaxQueue struct { Queue []int Max []int Size int } func Constructor() MaxQueue { return MaxQueue{ ...
分类:
其他好文 时间:
2020-03-07 20:41:23
阅读次数:
53
图论 坑 dij使用地图是带权图 记得初始化为INF 无边的权值是INF,不是0,并且这个INF别用INT_MAX这个宏,会导致出现一些问题,比如dij更新路径的时候,INT_MAX + 1会变成负值,出错,自己定义一个比较大的数就行了 思路与总结 与图相关的算法 dfs/bfs 最小生成树(pri ...
分类:
其他好文 时间:
2020-03-03 00:37:53
阅读次数:
128
一、题目 二、源程序代码 package test; import java.util.*; public class Array { public static void main(String []args) { int [] A= {1,-2,3,5,6}; int max=0; int a, ...
分类:
其他好文 时间:
2020-02-28 20:56:38
阅读次数:
53
某国的足球联赛中有N支参赛球队,编号从1至N。联赛采用主客场双循环赛制,参赛球队两两之间在双方主场各赛一场。 联赛战罢,结果已经尘埃落定。此时,联赛主席突发奇想,希望从中找出一条包含所有球队的“食物链”,来说明联赛的精彩程度。“食物链”为一个1至N的排列{ T?1?? T?2?? ? T?N?? } ...
分类:
其他好文 时间:
2020-02-28 14:05:45
阅读次数:
77
1、out参数 out参数要求在方法的内部必须为其赋值 using System; using System.Text; namespace Demo { class Program { //返回一个数组的最大值,最小值,均值,长度,名称 static void Main() { int max = ...
1 #include <bits/stdc++.h> 2 using namespace std; 3 4 const int MAX = 100; 5 char arr[MAX][MAX]; 6 int n,m; 7 8 void init(); 9 void solve(); 10 void d ...
分类:
其他好文 时间:
2020-02-25 17:38:14
阅读次数:
55