ICode9

精准搜索请尝试: 精确搜索
  • [LeetCode] 53. Maximum Subarray(最大子数组)2020-10-17 10:32:52

    Difficulty: Easy Related Topics: Array, Divide and Conqur, Dynamic Programming Link: https://leetcode.com/problems/maximum-subarray/ Description Given an integer array nums, find the contiguous subarray (containing at least one number) which has the

  • 654. Maximum Binary Tree2020-10-09 04:32:40

    Given an integer array with no duplicates. A maximum tree building on this array is defined as follow: The root is the maximum number in the array. The left subtree is the maximum tree constructed from left part subarray divided by the maximum number. Th

  • 414. Third Maximum Number2020-10-06 19:33:53

    package LeetCode_414 /** * 414. Third Maximum Number * Given a non-empty array of integers, return the third maximum number in this array. * If it does not exist, return the maximum number. The time complexity must be in O(n). Example 1: Input: [3, 2,

  • CF1092F Tree with Maximum Cost(换根dp)2020-10-02 19:33:31

    刷了这么久终于遇到水题,十分套路的换根dp,先自底向上维护,之后自顶向下维护一遍 #include<bits/stdc++.h> using namespace std; typedef long long ll; const int N=4e5+10; int h[N],e[N],ne[N],idx; int sz[N]; ll f[N],g[N]; ll a[N]; ll son[N],up; int n; void add(int a,in

  • 421. Maximum XOR of Two Numbers in an Array2020-09-17 04:01:26

    Given a non-empty array of numbers, a0, a1, a2, … , an-1, where 0 ≤ ai < 231. Find the maximum result of ai XOR aj, where 0 ≤ i, j < n. Could you do this in O(n) runtime? Example: Input: [3, 10, 5, 25, 2, 8] Output: 28 Explanation: The maximum re

  • 1537. Get the Maximum Score2020-08-12 05:00:31

    You are given two sorted arrays of distinct integers nums1 and nums2. A valid path is defined as follows: Choose array nums1 or nums2 to traverse (from index-0). Traverse the current array from left to right. If you are reading any value that is pre

  • 题解 CF1081D 【Maximum Distance】2020-08-08 21:32:33

    题目,洛谷博客 是一道最小生成树的题目。 用的是 \(kruskal\) 。 其他不多说,就讲一下为什么最后输出 \(ans\) \(k\) 次。 假设一个点到另一个点的最大值比现在小,那么其他的点也会走这条路。 所以上代码。 #include<bits/stdc++.h> #define FOR(i,j,k) for(int i=(j);i<=(k);i++)

  • leetcode53 - Maximum Subarray - easy2020-08-07 12:02:10

    Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum. Example: Input: [-2,1,-3,4,-1,2,1,-5,4], Output: 6 Explanation: [4,-1,2,1] has the largest sum = 6.   Greedy, 每个小

  • 打印二叉树2020-07-19 16:33:14

    参考:波兰表示法与表达式树 在终端上打印一个数据类型为int的二叉树,方便调试红黑树 实现效果 第二行为后序数组,第三行为中序数组 源码 struct node { int data; node *l, *r; }; int maxDepth(const node *n) { if (n == nullptr) return 0; else {

  • 239. 滑动窗口最大值(Sliding Window Maximum)2020-07-11 11:07:20

    题目描述: 给定一个数组 nums,有一个大小为 k 的滑动窗口从数组的最左侧移动到数组的最右侧。你只可以看到在滑动窗口内的 k 个数字。滑动窗口每次只向右移动一位。 返回滑动窗口中的最大值。   进阶: 你能在线性时间复杂度内解决此题吗?   示例: 输入: nums = [1,3,-1,-3,5,3,6,

  • Cocos Creator Rect width exceeds maximum margin报错2020-07-01 22:37:32

    版本:2.3.4   今天换场景地图,就替换了几张图片。然后cocos creator里就报错 Rect width exceeds maximum margin。     删除原来的图片和meta文件,重新放入也没有用。 这几张图是用于Tiled里拼接地图的,后来我重新建了图块集tsx,重新摆地图tmx,然后报错消失。也不知道咋回事。这

  • Codeforces Round #651 (Div. 2) A. Maximum GCD (思维)2020-06-21 15:04:33

    题意:在\(1\)~\(n\)中找两个不相等的数使得他们的\(gcd\)最大. 题解:水题,如果\(n\)是偶数,那么一定取\(n\)和\(n/2\),\(n\)是奇数的话,取\(n-1\)和\((n-1)/2\). 代码: #include <iostream> #include <cstdio> #include <cstring> #include <cmath> #include <algorithm

  • MMD :maximum mean discrepancy2020-06-16 15:03:24

    MMD :maximum mean discrepancy MMD :maximum mean discrepancy(最大平均差异) MMD:maximum mean discrepancy。最大平均差异。最先提出的时候用于双样本的检测(two-sample test)问题,用于判断两个分布p和q是否相同。它的基本假设是:如果对于所有以分布生成的样本空间为输入的函数f,如果

  • Codeforces Round #648 (Div. 2) E - Maximum Subsequence Value 思维2020-06-12 21:57:07

    自己动手模拟一下就好,最多三个数 #include<map> #include<queue> #include<time.h> #include<limits.h> #include<cmath> #include<ostream> #include<iterator> #include<set> #include<stack> #include<cstdio> #include<

  • postgres 流复制集群--主备切换(二)2020-06-09 10:52:21

    一,主备查看与使用   01,pg_controldata  --主机信息 [postgres@kafka01 pgdata]$ pg_controldata -D /data/pgdata/ pg_control version number: 1002 Catalog version number: 201707211 Database system identifier: 6818043668731457858

  • 962. Maximum Width Ramp2020-05-29 15:04:45

    问题: 给定数组,求一对 index为 ( i , j ) 的 A[i] <= A[j] && i < j,两个index距离最远。(即max(j-i)) Example 1: Input: [6,0,8,2,1,5] Output: 4 Explanation: The maximum width ramp is achieved at (i, j) = (1, 5): A[1] = 0 and A[5] = 5. Example 2: Input: [9,8,1,0,

  • Leetcode练习(Python):滑动窗口:第239题:滑动窗口最大值:给定一个数组 nums,有一个大小为 k 的滑动窗口从数组的最左侧移动到数组的最右侧。你只可以看到在滑动窗口内的 k 个数字2020-05-26 17:56:08

    题目: 滑动窗口最大值:给定一个数组 nums,有一个大小为 k 的滑动窗口从数组的最左侧移动到数组的最右侧。你只可以看到在滑动窗口内的 k 个数字。滑动窗口每次只向右移动一位。  返回滑动窗口中的最大值。  进阶: 你能在线性时间复杂度内解决此题吗?   示例: 输入: nums = [1,3,-1,-

  • 学车->背书2020-05-21 20:04:24

    倒车入库左边:向前到座位对出去红线向左打450,车直了回0,差不多了停车。向后到座位对出去红线了向左打maximum,看反光镜,车尾碰到地上红点回到360,等车进车位左右较均匀时回0,之后稍加调整。右边:向前到座位对出去红线向右打450,车对出去到白线结束处停车。方向盘不动,向后到座位对出去红点

  • RangeError: Maximum call stack size exceeded2020-05-20 10:09:48

       因为在获取token值的时候没有进行字符串转接 造成了“最大堆栈超过了最大值” 解决方法:     就是将其转化数组类型之前,都先确保它是String类型(也可以是非数组类型),就不会多层嵌套,产生Uncaught RangeError: Maximum call stack size exceeded这样报错了  

  • LC 918. Maximum Sum Circular Subarray2020-05-16 09:07:39

    link     class Solution { public: int maxSubarraySumCircular(vector<int>& A) { int maxsum=INT_MIN; int minsum=INT_MAX; int total=0; int curmax=0; int curmin=0; for(int i=0;i<A.size();i++){

  • 718. Maximum Length of Repeated Subarray2020-05-04 12:54:38

    问题: 给定两个数组,求两个数组中最长公共子数组的长度。 Example 1: Input: A: [1,2,3,2,1] B: [3,2,1,4,7] Output: 3 Explanation: The repeated subarray with maximum length is [3, 2, 1]. Note: 1 <= len(A), len(B) <= 1000 0 <= A[i], B[i] < 100    解法: DP动态

  • LeetCode 53. 最大子序和2020-05-03 09:51:37

    package 数组; /** * https://leetcode-cn.com/problems/maximum-subarray/ * 题解:https://leetcode-cn.com/problems/maximum-subarray/solution/hua-jie-suan-fa-53-zui-da-zi-xu-he-by-guanpengchn/ * 53. 最大子序和 * * 1、动态规划的是首先对数组进行遍历,当前最大连续

  • LeetCode T53.Maximum Subarray/最大子序和2020-05-03 09:03:41

       这类题目的往往可以采用暴力穷举的办法,但其时间复杂度过高。因此,这里采用动态规划的方法求解。设定一个状态集合dp[numsSize]与nums[numsSize]一一对应,对dp[0]初始化为nums[0],之后的每一个状态都赋值为max{nums[i], nums[i]+dp[i-1]},这里的意思就是每往后扫描一个元素,返回该

  • 646. Maximum Length of Pair Chain2020-04-18 09:03:06

    Problem: You are given n pairs of numbers. In every pair, the first number is always smaller than the second number. Now, we define a pair (c, d) can follow another pair (a, b) if and only if b < c. Chain of pairs can be formed in this fashion. Given a

  • CF886E Maximum Element2020-04-15 10:04:08

    Link 不难发现,返回值错误当且仅当在$n$的前面,存在连续的$k$个数,使得这$k$个数均小于这$k$个数前面的最大值。 设$f_i$表示长度为$i$的未由if(offset==k)return ans;返回的排列个数。 枚举$i$所在的位置$j$,转移为$f_i=\sum\limits_if_{i-1\choose i-j}(i-j)!=(i-1)!\sum\limits_\fr

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有