ICode9

精准搜索请尝试: 精确搜索
  • 二叉搜索树与双向链表 深度搜索 遍历二叉树 双向链表2022-04-27 20:35:17

    https://leetcode-cn.com/problems/er-cha-sou-suo-shu-yu-shuang-xiang-lian-biao-lcof/ """ # Definition for a Node. class Node(object): def __init__(self, val, left=None, right=None): self.val = val self.left = left

  • PAT Advanced Level 1011 World Cup Betting2022-04-27 08:31:44

    原题传送门 1. 问题描述 2. Solution 1、思路分析 题目大意:给出三场比赛以及每场比赛的W、T、L的赔率,选取每一场比赛中赔率最大的三个数a b c,先输出三行各自选择的是W、T、L中的哪一个,然后根据计算公式 (a * b * c * 0.65 – 1) * 2 得出最大收益~ 分析:以三个数一组的形式读取,读取

  • LeetCode 0082 Remove Duplicates from Sorted List II2022-04-27 08:00:38

    原题传送门 1. 题目描述 2. Solution 1 1、思路分析 递归写法。 1> 递归出口。遍历到链表的末尾,直接返回当前遍历结点。 2> 规模递减。如果当前结点值与其后继结点值不相等,处理后继结点,把处理结果挂到当前结点后面。如果当前结点与其后继结点相等,遍历链表,找到不重复的结点,处理不

  • LeetCode 0083 Remove Duplicates from Sorted List2022-04-27 08:00:17

    原题传送门 1. 题目描述 2. Solution 1 1、思路分析 迭代法。 2、代码实现 package Q0099.Q0083RemoveDuplicatesfromSortedList; import DataStructure.ListNode; public class Solution2 { public ListNode deleteDuplicates(ListNode head) { if (head == null

  • LeetCode 0084 Largest Rectangle in Histogram2022-04-27 08:00:06

    原题传送门 1. 题目描述 2. Solution 1 1、思路分析 方法1: 暴力方法(Time Limit Exceeded) - 面积 = 底 x 高 - 固定底,求最大高度不好求 - 固定高,求最长底边好求 - 从i向两边遍历,找到左边和右边第1个严格小于height[i]的时候停下,中间的长度就是最长底边 2、代码实现 package Q00

  • js reduce用法详解2022-04-27 00:31:06

    前言    reduce() 方法对数组中的每个元素执行一个由您提供的reduce函数(升序执行),将其结果汇总为单个返回值。reduce方法可做的事情特别多,就是循环遍历能做的,reduce都可以做,比如数组求和、数组求积、数组中元素出现的次数、数组去重等等。 语法 arr.reduce(function(prev,cur,i

  • Makefile2022-04-27 00:02:59

      ROOTFS_DIR = /opt/4412/rootfs MODULE_NAME = led_drvAPP_NAME = led_test CROSS_COMPILE = /home/george/Linux_4412/toolchain/gcc-4.6.4/bin/arm-none-linux-gnueabi-CC = $(CROSS_COMPILE)gcc ifeq ($(KERNELRELEASE), ) KERNEL_DIR = /home/george/Linux_4412/kernel/

  • 「NOI2019」斗主地2022-04-26 19:31:06

    「NOI2019」斗主地 Part 30 考虑每次洗牌转移一次 设\(f_{i,j}\) 为第一堆牌选出 \(i\) 张,第二堆牌选出 \(j\) 张的概率。设 \(Ans_i\) 为从下往上数第 \(i\) 张的期望分数。 枚举根据定义转移即可。转移式不难写就不写了 Part 40 每个 \(A_i\) 相同,套个矩阵。 Part 100 不难发现

  • PAT Advanced Level 1008 Elevator2022-04-26 07:01:07

    原题传送门 1. 问题描述 2. Solution 1、思路分析 题目大意:电梯从0层开始向上,给出该电梯依次按顺序停的楼层数,并且已知上升需要6秒/层,下降需要4秒/层,停下来的话需要停5秒,问走完所有需要停的楼层后总共花了多少时间~ 分析:累加计算输出~now表示现在的层数,a表示将要去的层数,当a > now,

  • 相同概率获取元素 O(N)2022-04-25 14:00:06

    相同概率获取元素O(n) public static void main(String[] args) {       //随机获取元素为3的下标       int target = 3;       Random random = new Random();       int[] arr = {1, 2, 3, 3, 3, 4, 5};       int cur = 0;       int res = 0;  

  • 数据结构与算法知识点总结(5)查找树2022-04-25 13:02:12

    1.基础查找   符号表是一种典型的ADT,它提供了操作键值对的方法: put(插入、insert)、search、delete操作,这一节将会给出两种初级的符号表: 无序链表中的顺序查找、基于有序数组二分查找的有序符号表。   在某些实现中我们认为保持键的有序性并大大扩展它的API是很有用。例如

  • AtCoder Beginner Contest 249题解2022-04-23 23:01:51

    AtCoder Beginner Contest 249 A\(\sim\) D题解 A - Jogging 题目描述:A , B两人在散步,给你他们的速度和散步多少时间后需要休息多久,问到达指定时间后,谁走在前面。 思路:根据题意模拟即可 时间复杂度:\(O(1)\) 参考代码: void solve() { auto cal = [](int a, int b, int c, int x)->

  • 链表2022-04-23 14:32:33

    链表专题 学前必看:论如何4个月高效刷满 500 题并形成长期记忆 203. 移除链表元素 思路: 1)删除头部相同的val 2)来到第一个不是val的位置 /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode() : val(0

  • js去除数组对象中的重复对象2022-04-22 14:32:01

    const list = [ {id: 1, text: 文本1} {id: 1, text: 文本1} {id: 1, text: 文本1} {id: 2, text: 文本2} ] // 过滤方法 const filterList = (arr, id) => { let newList = arr.reduce((pre, cur) => pre.some(item => item[id] === cur[id]) ? pre : [..

  • P4206 [NOI2005] 聪聪与可可2022-04-22 13:00:25

    预处理 nxt[i,j] 表示i到j最近距离i的下一个位置 最后记忆化搜索就好 #include<cstdio> #include<queue> #include<cstring> #include<iostream> using namespace std; int cur,n,m,s,t; int head[1005],p[1005]; int dis[1005][1005],nxt[1005][1005]; bool vis[1005],visit[

  • 省选日记 Day11 - Day152022-04-21 17:34:47

    省选日记 Day \(11\) - Day \(15\) Day \(11\) Apr 14, 2022, Thursday SDOI2019 染色 一开始一眼看出 \(O(n^3)\) 的做法, 设 \(f_{i, j, k}\) 表示计算到第 \(i\) 列, \((i, 1)\) 为颜色 \(j\), \((i, 2)\) 为颜色 \(k\) 的方案数. 统计 \(U_{i, j}\) 作为所有 \(f_{i, j, x}\)

  • 牛客华为机试HJ632022-04-21 07:33:02

    原题传送门 1. 题目描述 2. Solution 1 1、思路分析 遍历所有的长度为n的子串,统计每个子串的字符串g、c出现次数,保存g、c出现次数最多的子串为最终答案。 2、代码实现 import sys if sys.platform != "linux": file_in = open("input/HJ63.txt") sys.stdin = file_in

  • 牛客华为机试HJ642022-04-21 07:32:46

    原题传送门 1. 问题描述 2. Solution 滑动窗口 import sys if sys.platform != "linux": file_in = open("input/HJ64.txt") sys.stdin = file_in def solve(n, s): cur = 1 start = 1 for c in s: if c == 'U':

  • 牛客华为机试HJ352022-04-20 08:01:42

    原题传送门 1. 问题描述 2. Solution 1、思路分析 找规律 0 | 1 3 6 10 1 | 2 5 9 2 | 4 8 3 | 7 0 1 0 2 1 0 3 2、代码实现 import sys if sys.platform != "linux": file_in = open("input/HJ35.txt") sys.stdin = file_in """ 0 | 1 3 6 10 1 | 2

  • LeetCode-152-乘积最大子数组2022-04-19 22:02:59

    乘积最大子数组 题目描述:给你一个整数数组 nums ,请你找出数组中乘积最大的连续子数组(该子数组中至少包含一个数字),并返回该子数组所对应的乘积。 示例说明请见LeetCode官网。 来源:力扣(LeetCode) 链接:https://leetcode-cn.com/problems/maximum-product-subarray/ 著作权归领扣网络

  • leetcode301 删除无效的括号2022-04-18 11:35:57

    思路: dfs+剪枝。 实现: 1 class Solution { 2 public: 3 int maxn=0;//已经找到的最大合法长度 4 void dfs(string&s,int cur,int cnt,string c,vector<string>&res,int maxp){ 5 int l=s.length(); 6 if(cur==l){ 7 if(cnt==0){ 8

  • 前缀树-TrieTree2022-04-17 15:00:32

    # 只处理了ascii字符 local Node = {} Node.__cname = "util.TrieTree.Node" Node.__index = Node function Node.new(v) local obj = {} setmetatable(obj, Node) obj:ctor(v) return obj end function Node:ctor(v) self.value = v self.pas

  • D2. 388535 (Hard Version)2022-04-16 18:02:57

    (所以这题为什么叫388535 题意:有一个[l,r]的排列,现在将里面每个数和x异或,得到一个新的数组,现在把这个数组打乱后给你,让你求x。 解0.5:数字的个数是奇数的时候可以把所有数异或一边,排列消掉,剩下的就是x;是偶数的时候按位看,如果相同的一位上0的数量和原来不一致,说明x对应的一位为1。 ha

  • L2-040 哲哲打游戏2022-04-16 18:02:36

    这题读懂题目之后就发现它很呆 #include <bits/stdc++.h> using namespace std; const int N = 100010, M = 110; vector<int> g[N]; int main() { ios::sync_with_stdio(false); cin.tie(0); int n, m; cin >> n >> m; for (int i = 1; i &

  • 109 后缀自动机(SAM)2022-04-16 10:02:33

    视频链接:                         P3804 【模板】后缀自动机 (SAM)。 // Luogu P3804 【模板】后缀自动机 (SAM) #include <iostream> #include <cstring> #include <algorithm> using namespace std; typedef long long LL; const int N=2e6+10; int h[N], e[N],

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

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

ICode9版权所有