ICode9

精准搜索请尝试: 精确搜索
  • [LeetCode]818. Race Car|BFS & DP附图详解(JavaScript版)2022-05-17 06:00:07

    题目描述  LeetCode原题链接:818. Race Car Your car starts at position 0 and speed +1 on an infinite number line. Your car can go into negative positions. Your car drives automatically according to a sequence of instructions 'A' (accelerate) and 'R&

  • 797. 所有可能的路径(图的遍历)2022-05-17 00:04:23

      难度中等284 给你一个有 n 个节点的 有向无环图(DAG),请你找出所有从节点 0 到节点 n-1 的路径并输出(不要求按特定顺序)  graph[i] 是一个从节点 i 可以访问的所有节点的列表(即从节点 i 到节点 graph[i][j]存在一条有向边)。   示例 1: 输入:graph = [[1,2],[3],

  • P6348 [PA2011]Journeys2022-05-16 16:00:07

    P6348 [PA2011]Journeys 题目描述 一个星球上有 n 个国家和许多双向道路,国家用 \(1\sim n\) 编号。 但是道路实在太多了,不能用通常的方法表示。于是我们以如下方式表示道路:\((a,b),(c,d)\)表示,对于任意两个国家 \(x,y\),如果 \(a\le x\le b,c\le y\le d\),那么在 \(x,y\) 之间有一条

  • 12:左叶子之和2022-05-12 01:00:31

    title: 左叶子之和

  • JZ043往完全二叉树添加节点2022-05-11 00:33:32

    ------------恢复内容开始------------ title: 往完全二叉树添加节点

  • LeetCode 0103 Binary Tree Zigzag Level Order Traversal2022-05-10 09:04:22

    原题传送门 1. 题目描述 2. Solution 1 1、思路分析 使用BFS+递归,逐层遍历树,若当前层level为奇数,头插结点;若当前level为偶数,尾插结点。 2、代码实现 package Q0199.Q0103BinaryTreeZigzagLevelOrderTraversal; import DataStructure.TreeNode; import java.util.ArrayList; imp

  • 游标2022-05-10 09:02:30

    什么是游标 用来存储多条查询数据的一种数据结构('结果集'), 它有一个 '指针',从上往下移动('fetch'),从而能够 '遍历每条记录' 基本写法 -- 测试基础数据 create table stu_info ( id number(3), name varchar2(30), sex varchar2(2) ); insert into stu_info(id, name, sex

  • JZ012左右两边子数组的和相等2022-05-09 22:01:15

    title: 左右两边子数组的和相等

  • 面试题 04.06. 后继者2022-05-08 21:34:14

    题目表述 设计一个算法,找出二叉搜索树中指定节点的“下一个”节点(也即中序后继)。 如果指定节点没有对应的“下一个”节点,则返回null。 示例 1: 输入: root = [2,1,3], p = 1 2 / 1 3 输出: 2 解题思路 只有两种情况 p没有右子树 p有右子树 如果有右子树的话,那么只需要直接根

  • 8.1:双向链表实现双端队列2022-05-08 11:03:04

    8.1:双向链表实现双端队列   双端队列,玩的head 和tail指针     1、双向链表   1 public static class Node<T> { 2 public T value; 3 public Node<T> last; 4 public Node<T> next; 5 6 public Node(T data) { 7 value = dat

  • leetcode(c++)(扫描线)2022-05-07 07:32:34

    #include <iostream> #include <vector> #include <unordered_map> #include <queue> #include <algorithm> using namespace std; bool cmp(pair<int,int>&p1,pair<int,int>&p2) { if(p1.first == p2.first)return

  • 7.2:链表删除给定值2022-05-06 19:03:40

    7.2:链表删除给定值   1 public static Node removeValue(Node head, int num) { 2 // head来到第一个不需要删的位置 3 while (head != null) { 4 if (head.value != num) { 5 break; 6 } 7 head =

  • 刷题-力扣-面试题 16.10. 生存人数2022-05-04 20:02:50

    题目链接 来源:力扣(LeetCode) 链接:https://leetcode-cn.com/problems/living-people-lcci 著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。 题目描述 给定 N 个人的出生年份和死亡年份,第 i 个人的出生年份为 birth[i],死亡年份为 death[i],实现一个方法以计算生

  • leetcode524 通过删除字母匹配到字典里最长单词2022-05-04 14:00:32

    思路: 双指针+序列自动机优化。 实现: 1 class Solution 2 { 3 public: 4 bool check(string&s,string&t,vector<vector<int>>&dp){ 5 int n=s.length(),m=t.length(); 6 int cur=0; 7 for(int i=0;i<m;i++){ 8

  • 【插头DP】【学习笔记】2022-05-04 12:04:05

    【插头DP】【学习笔记】 Tips: 虽然插头Dp模板是黑的,但其实算法并不难理解,用到的只是轮廓线dp+哈希表而已,比较复杂的是讨论多种情况的转移和位运算,但封装几个函数以后,代码也十分简单了。 模板 Solution 首先考虑状压dp,考虑需要哪些状态,如果仅仅知道每个格子是否有向下伸出的插头是

  • 剑指offer(43)2022-05-04 08:32:51

    剑指offer(43) 剑指 Offer 43. 1~n 整数中 1 出现的次数 输入一个整数 n ,求1~n这n个整数的十进制表示中1出现的次数。 例如,输入12,1~12这些整数中包含1 的数字有1、10、11和12,1一共出现了5次。 示例 1: 输入:n = 12 输出:5 示例 2: 输入:n = 13 输出:6 限制: 1 <= n < 2^31 思路: ​ 本题

  • leetcode(c++)(并查集)2022-05-03 20:33:55

    #include <iostream> #include <vector> using namespace std; class DSU{ public: vector<int>parent; DSU(int n) { parent = vector<int>(n); for(int i = 0; i< n; ++i) { parent[i] =

  • P3371 最短路2022-05-03 20:03:05

    原题洛谷P3371 建边+dijstra找最短路   #include<bits/stdc++.h> using namespace std; struct E //边 { long long v; long long next; long long w; }ed[500001]; long long head[500001],acti; bool b[700000];//标记 long long d[700000];//权 long long n,m

  • 学习随笔2022-05-02 21:33:38

    今天继续LeetCode上的题,明天准备写写最近学的springmvc 题目一:剑指Offer上的从尾到头打印链表,就是从链表的尾部输出链表,而且用数组返回,思路是利用栈的特点,完成 public class Office06 { public static void main(String[] args) { ListNode head=null; //使

  • 写代码, 无意中摸了下算法:)2022-05-02 20:02:56

      今天继续撸一个下载器的时候, 一个 progressbar 控件报 Maximum 超限了 调试看了下,真的会超,Maximum 属性 是 int32 的,但是数据可能会是 long (int64),超限了就会导致崩溃。   Lv1: 开始就想着 value/10000 好了 max = org_MaxValue / 10000; cur = org_CurValue / 10000; //

  • 题解 - P44222022-05-02 16:32:24

    Code first, then talk // Type: se_tr #include<bits/stdc++.h> using namespace std; struct node{ node *ls, *rs; int lb, rb, mi; node () { mi = 0x3f3f3f3f; ls = rs = NULL; } }; void build(node *cur, int lb, int rb){ cur -> lb = lb; cur -&

  • 使用python或Navicat连接OpenGauss数据库2022-05-01 00:33:47

    最近在学习华为的数据库,在学习如何用python来连接数据的时候,一直连接失败,然后官方文档也没有具体说明如何用python来连接,然后被这个东西困扰了我好几天。在网上找了很多资料,终于成功用python连接上了OpenGauss数据库。 在OpenGauss的官方文档中,找到了用于连接OpenGauss数据库的库,P

  • 2021CCPC女生赛2022-04-30 20:35:01

    这篇题解题目的顺序是按照我认为的难度顺序来的。 K.音乐游戏   把每一行的字符串读进来之后,直接去计算这个字符串中有多少个\("-"\)字符就可以了 int n; std::cin >> n; i64 ans = 0; rep(i,0,n + 1) { // for (int i = 0; i < n + 1; i ++ ) 读到n + 1的原因是getline读取字符

  • 力扣78题2022-04-29 17:02:28

    方法一: binary 不使用递归 class Solution { public: vector<vector<int>> subsets(vector<int>& nums) { vector<vector<int>> ans; int n = nums.size(); for (int i = 0; i < 1 << n; i ++ ) {

  • mysql-学习01 数据库存储过程操作2022-04-28 13:00:16

    一、批量插入 1)for循环调用Dao中的单条插入方法 2)传一个List<Object>参数,使用Mybatis的批量插入 (foreach) 对于批量插入它的Mapper看起来向这样 CREATE DEFINER=`root`@`localhost` PROCEDURE `insert_exam`(in studentid0 int)BEGIN DECLARE examid0 int; declare fromc0 int; dec

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

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

ICode9版权所有