Algorithm

Data structure and algorithm-Two

B树 扩容 找出不含重复字符的最长字串的长度 字母异位词分组 优化用一个长度26的整数数组来标识 ArrayKey的构造方法 判断是否存在重复元素 借鉴HashSet后的小优化版 put 自带一个返回值,返回的是添加前原位置的元素,若原位置为空,则返回null 添加,若遇到重复元素,则在集合中删除, ......
algorithm-Two structure algorithm Data and

[Algorithm] LRU Cache

An LRU (Least Recently Used) cache is a type of data structure that maintains a limited size of items and evicts the least recently accessed item when ......
Algorithm Cache LRU

Data structure and algorithm-One

右边界左边界 函数式编程 传统的实现方式通常是将具体的功能代码直接写在方法内部。这样的实现方式对于固定的功能来说可能是足够的,但它的灵活性和复用性较低。每当需要不同的功能时,您需要编写新的方法或修改原有方法,这可能会导致代码的冗余和不易维护。 而函数式编程的优点在于它将函数本身作为参数传递,使得调用 ......
algorithm-One structure algorithm Data and

[Algorithm] Compare two Binary tree are the same in both value and shape

export default function compare( a: BinaryNode<number> | null, b: BinaryNode<number> | null, ): boolean { if (a null && b null) { return true; } if (a ......
Algorithm Compare Binary shape value

[Algorithm] Path maze solver - recursive

// Base case // 1. Off the map // 2. Hit a wall // 3. Already visited // 4. It's the end const dirs = [ [1, 0], //top [0, 1], //right [-1, 0], //botto ......
Algorithm recursive solver Path maze

A Randomized Algorithm for Single-Source Shortest Path on Undirected Real-Weighted Graphs 部分翻译

A Randomized Algorithm for Single-Source Shortest Path on Undirected Real-Weighted Graphs Ran Duan , Jiayi Mao , Xinkai Shu , and Longhui Yin 这篇翻译必定有相 ......

Windows使用PyTorch遇到RuntimeError: Unable to find a valid cuDNN algorithm to run convolution的解决方案

Windows使用PyTorch遇到RuntimeError: Unable to find a valid cuDNN algorithm to run convolution的解决方案 PyTorch在Windows上的cuDNN实现有问题才会导致这个错误,解决方法是禁用cuDNN滚回旧实现上 ......

[Algorithm] Two crystal balls problem

You're given two identical crystal balls and a 100-story building. The balls are incredibly tough, but there exists some floor in the building, above ......
Algorithm crystal problem balls Two

Leetcode: Algorithm

1. Boyer-Moore Voting Algorithm identify the majority element (frequency > n/2) class Solution { public int majorityElement(int[] nums) { int count = ......
Algorithm Leetcode

Comparing with traditional convex optimization methodology, what are advantages of PSO algorithm

与传统的凸优化方法相比,粒子群算法有哪些优点 与传统的凸优化方法相比,粒子群优化(PSO)算法具有以下优点: 全局搜索能力:PSO算法具有较强的全局搜索能力,能够在多个解空间中寻找最优解。由于粒子群在搜索过程中可以通过信息共享和合作,有助于避免陷入局部最优解。 适应性和自适应性:PSO算法具有适应性 ......

智能计算理论:Please write down the procedure of PSO algorithm.

粒子群优化(Particle Swarm Optimization,PSO)算法是一种基于种群的优化算法,灵感来源于鸟群或鱼群的社会行为。下面是PSO算法的一般过程: 初始化粒子群:创建一个粒子群,其中每个粒子表示问题的一个潜在解。在搜索空间内随机初始化粒子的位置和速度。 评估适应度:根据每个粒子的 ......
algorithm procedure 理论 智能 Please

JavaScript Algorithm: FizzBuzz javascript fizzbuzz问题

We are going to write a function called fizzbuzz that will accept no arguments. The goal of this function is to print out all numbers from 1 to 100 bu ......

STL-algorithm(ACM)

unique(a.begin(), a.end()) 待研究 与离散化有关 // 翻转(reverse(位置,位置)) reverse(a.begin(), a.end()); int a[5] = {1, 2, 3, 4, 5}; reverse(a, a + 5); // 结果 5 4 3 2 ......
STL-algorithm algorithm STL ACM

algorithm库的使用

# 算法库(algorithm) ## 1. 什么是algorithm? algorithm库装满了好用的库函数,一般由`#include `包含。~~可是本蒻蒻还是喜欢万能头(逃~~ ## 2. 经典的库函数 ### (1) sort()函数 ```cpp sort(begin, end, cmp ......
algorithm

algorithm库的使用

# 算法库(algorithm) ## 1. 什么是algorithm? algorithm库装满了好用的库函数,一般由`#include `包含。~~可是本蒻蒻还是喜欢万能头(逃~~ ## 2. 经典的库函数 ### (1) sort()函数 ```cpp sort(begin, end, cmp ......
algorithm

Algorithm_03--C#排序算法(选择排序)

选择算法本质:1、找到数组中最小的元素 2、将其放在第一位 3、找到数组第二小的元素 4、将其放在第二位 5、以此类推,直到整个数组排序 ......
算法 Algorithm 03

蒙哥马利算法(Montgomery Algorithm)

[TOC] > 如何计算$x\cdot y \mod N$? ## 传统的模乘运算 在$Z_{1024}$中,将其中一个数$x$表示成$x = \displaystyle\sum_{i=0}^{1023} a_i \cdot 2^i$,于是,乘法运算可以写为 $$ x\cdot y \mod N = ......
算法 Montgomery Algorithm

CSSYZ Algorithm Round #2

# [ABC192F] Potion ## 分析 设选择的总和为 $sum$。 不难发现: $x\%k=sum\%k$。 又因为: $ans=(x-sum)/k$。 不难发现$sum$只与$\%k$有关,且当$k$一定时,$sum$越大,$ans$越小。 因为$k$的值域很小,显然可以对于每一个$k ......
Algorithm CSSYZ Round

排序算法(sorting algorithm) 之 归并排序(merge sort)

初版(探索):运行很慢,写法有问题 import java.util.Arrays; import cn.hutool.core.util.RandomUtil; public class MergeSortTest { public static void main(String[] args) ......
算法 algorithm sorting merge sort

启发式算法(heuristic algorithm)

运筹学--Operations Research (O.R.),有时也称为**数学规划、最优化理论**,是人工智能的“引擎”,因为几乎所有人工智能的问题最后都会转化为求解优化问题。几年前流行的支持向量机(SVM,二次规划问题)如此,近几年席卷全球的深度学习(DL)的参数优化(训练)也是(高度复合函数 ......
算法 heuristic algorithm

Algorithm_02--C#排序算法(升序)

(升序)算法原理: 通过重复比较和交换,使较大的元素逐渐“浮”到数组后面。 具体步骤: 1.比较相邻元素,如果第一个比第二大,就交换它们两个。 2.对每一对相邻元素作同样的工作,从开始第一到结尾的最后一对。这样再最后的元素应该会是最大数。 3.针对所有的元素重复以上的步骤,除了最后一个。 4.重复步 ......
升序 算法 Algorithm 02

Algorithm_01--C#递归算法02

///递归算法本质: ///1、方法的自我调用 ///2、有明确的终止条件 ///3、每次调用时,问题规模在不断减少。通过递减,最终到达终止条件 //一列数的规则如下:1、1、2、3、5、8、13、21、34..求第30位数是多少 ![](https://img2023.cnblogs.com/bl ......
算法 Algorithm 01

Algorithm_01--C#递归算法

递归算法本质: 1、方法的自我调用 2、有明确的终止条件 3、每次调用时,问题规模在不断减少。通过递减,最终到达终止条件 ......
算法 Algorithm 01

Cluster-GCN An Efficient Algorithm for Training Deep Convolution Networks

Chiang W., Liu X., Si S., Li Y., Bengio S. and Hsieh C. Cluster-GCN: An efficient algorithm for training deep and large graph convolutional networks. ......

algorithm:算法库

#include <algorithm>using namespace std;// 常用函数sort(begin, end); // 对区间进行排序reverse(begin, end); // 对区间进行翻转rotate(begin, middle, end); // 将区间按照middle为界 ......
algorithm

LeetCode:Search Algorithm

LeetCode:Search Algorithm 1\First unique char Algorithm Design 利用字符数量的有限性,通过数组来映射(避免Hash_map的高复杂度) 注意数组声明为int A[26]而不是char A[26]; if(s=="") return ' ' ......
Algorithm LeetCode Search

npm run的时候遇到报错: this[kHandle] = new _Hash(algorithm, xofLen);

1、问题: 2、解决方案:直接在package.json文件里面加上set NODE_OPTIONS openssl-legacy-provider如下: 解决方案参考连接:https://blog.csdn.net/lingshuanglong/article/details/127880752 ......
algorithm kHandle 时候 xofLen Hash

「算法学习」exkmp(Z Algorithm)

定义 $z_i$ 为 $[i,n)$ 与 $[0,n)$ 的 $\mathrm {lcp}$。 令当前 $[l,r]$ 与 $[1,r-l+1]$ 是匹配的,且为我们当前知道的 $r$ 最大的区间(贪心)。现在我们递推求 $z_i$。(算法执行的过程中 $i\leqslant l$)。 根据这个匹配 ......
算法 Algorithm exkmp

强连通分量 - Kosaraju Algorithm

推荐在唯一官方原文阅读,但本文不是转载,是多平台发布。 Kosaraju算法(aka Kosaraju-Sharir算法)是一个求强连通分量的算法。其时间复杂度为$O(n+m)$(邻接表)或$O(m^2)$(邻接矩阵)。 该算法相比Tarjan算法要更简单一些。(个人观点) 本算法的基础是反图(也被 ......
分量 Algorithm Kosaraju

Algorithm参数记录

一、vector<Point2f> vector是一个存储二维点坐标的容器,其中每个元素都是一个Point2f类型的对象。在OpenCV中,Point2f表示一个由两个单精度浮点数构成的二维点坐标。 你可以使用vector来存储一些二维坐标信息,比如图像中的关键点或轮廓点等。具体用法可以参考下面的示 ......
Algorithm 参数