自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(24)
  • 资源 (2)
  • 收藏
  • 关注

原创 Torch 7 安装教程(Ubuntu 16.04 + CUDA 10.2)从宇宙大爆炸开始教

Torch 环境配置, Ubuntu 16.04, CUDA 10.2, cuDNN 7.6.5, Lua 5.2

2022-11-12 21:09:55 1966 1

原创 【MATLAB】构建WS小世界网络

分析:进行复杂网络相关研究的基础,就是要构建适当的网络模型。这次选择用Matlab构建一个WS小世界网络练练手。首先,为了方便数据处理,网络模型我们用邻接矩阵的表示,这样虽然看上去不太直观,但是对于矩阵运算是很友好的。小世界网络分为两种:NW小世界网络和WS小世界网络。它们的构造都基于一个初试的最近邻耦合网络A:也就是网络中每个节点都与左右相邻的各K/2个节点相连,其中参数K满足N&g...

2019-03-22 14:16:01 9046 5

转载 LeetCode.365.水壶问题

题目:两个容量分别为x升和y升的水壶盛出z升水。解答:链接:力扣官方题解思路一:DFS思路二:代数方法(贝祖定理)

2020-03-21 16:38:21 172

原创 [NP] 8.9

题目:题目分析:1、对于这个题目的理解:即对一组集合,要求找出规模在b以内的和每一个集合Si有交集的集合H。2、要证明该问题是一个NP问题,首先要验证对于任意一个假定的答案H是否符合问题对答案的要求,这里就对任意一个答案H作出分析:     1)对于集合H,首先判定起规模是否为b以内,这个步骤耗时为min(b,H.size());     2)其次利用遍历对每一个Si的元素

2017-07-10 15:01:59 392

原创 [DP]516. Longest Palindromic Subsequence

题目:Given a string s, find the longest palindromic subsequence's length in s. You may assume that the maximum length of s is 1000.Example 1:Input: "bbbab"Output:4One possible longest

2017-06-07 22:23:46 359

原创 [DP]392. Is Subsequence

题目:Given a string s and a string t, check if s is subsequence of t. You may assume that there is only lower case English letters in both s andt. t is potentially a very long (length ~= 500,000

2017-05-29 22:39:54 322

原创 [DP]343. Integer Break

题目:Given a positive integer n, break it into the sum of at least two positive integers and maximize the product of those integers. Return the maximum product you can get.For example, given n = 2

2017-05-28 17:04:25 243

原创 [DP]357. Count Numbers with Unique Digits

题目:Given a non-negative integer n, count all numbers with unique digits, x, where 0 ≤ x n.Example:Given n = 2, return 91. (The answer should be the total numbers in the range of 0 ≤ x < 100, e

2017-05-22 21:29:04 300

原创 [DP]413. Arithmetic Slices

题目:A sequence of number is called arithmetic if it consists of at least three elements and if the difference between any two consecutive elements is the same.For example, these are arithmetic

2017-05-15 10:54:54 264

原创 [DP]486. Predict the Winner

题目:Given an array of scores that are non-negative integers. Player 1 picks one of the numbers from either end of the array followed by the player 2 and then player 1 and so on. Each time a player pi

2017-05-09 13:57:08 759

原创 [DP]338. Counting Bits

题目:Given a non negative integer number num. For every numbers i in the range 0 ≤ i ≤ num calculate the number of 1's in their binary representation and return them as an array.Example:For num

2017-05-03 00:21:18 304

原创 [BFS]101. Symmetric Tree

题目:Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tree [1,2,2,3,4,4,3] is symmetric: 1 / \ 2 2 / \ / \3 4

2017-04-25 12:24:59 272

原创 [BFS]102. Binary Tree Level Order Traversal

题目:Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level).For example:Given binary tree [3,9,20,null,null,15,7], 3 / \

2017-04-25 11:34:23 215

原创 [BFS]107. Binary Tree Level Order Traversal II

题目:Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from left to right, level by level from leaf to root).For example:Given binary tree [3,9,20,null,n

2017-04-18 14:52:52 259

原创 [BFS]199. Binary Tree Right Side View

题目:Given a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see ordered from top to bottom.For example:Given the following binary tree,

2017-04-10 21:20:38 269

原创 [BFS]529. Minesweeper

【记又一次阵亡在“==”上的惨痛经历】题目:Let's play the minesweeper game (Wikipedia,online game)!You are given a 2D char matrix representing the game board. 'M' represents anunrevealed mine, 'E' represents

2017-04-03 12:27:27 543

原创 [DFS]515. Find Largest Value in Each Tree Row

题目:题目分析:1、题目要求通过给出的二叉树找出每行最大值。最后通过一个容器返回所有结果。2、这里注意找的是每一行的最大值,我们知道对于一个数组而言,最大值仅需遍历一遍即可;那么我们把每棵树当作若干数组的堆叠,仅需对每层进行一次遍历即可。很显然层序遍历的方法就是BFS。3、明确了通过BFS求解后,还需要解决细节上的问题。比如,在BFS的队列实现中,如何找到各层的起始和终止位置。

2017-03-28 10:43:12 479

原创 【讨论_图论】DFS问题(一)

原问题(算法概论P99 3.22)Give an efficient algorithm that takes as input a directed acyclic graph G = {V, E}, and determines whether or not there is a vertex s ∈ V from which all other vertices are reachable.

2017-03-21 18:53:52 656

原创 [DFS]513. Find Bottom Left Tree Value

题目:Given a binary tree, find the leftmost value in the last row of the tree.Example 1:Input: 2 / \ 1 3Output:1Example 2: Input: 1 / \ 2 3 / ...

2017-03-19 21:34:03 383

原创 [Divide and Conquer]240. Search a 2D Matrix II

题目:1、本题中给出的矩阵具有行列向均递增的特性,且矩阵由二重容器表示。要求检验元素target是否在矩阵当中。2、算法①最基本的算法为二重循环遍历一次矩阵即可,但是这样并没有用上矩阵行列递增的特点,算法复杂度达到了O(mn),这里考虑用更简单的办法解决之。②第二种算法考虑沿着矩阵对角线前进以节省时间。从matrix[0][0]出发,若比target小则i++,j++,如此循环

2017-03-12 23:30:46 345

原创 [Divide and Conquer]241. Different Ways to Add Parentheses

题目:题目分析:1、根据题目要求,函数的输入为一个只涉及"+"、"-"、"×"三种运算的字符串。需要根据输入计算出所有可能计算顺序所对应的结果,并返回包含所有答案的Vector(升序)。2、问题一:怎么才能算出所有可能的顺序呢?很明显如果按照排列组合的方式依次添加括号,再利用栈的计算方法得出结果,涉及的代码量巨大且容易出错和遗漏。这里考虑用分治(递归)的方法解决;假设一个字...

2017-03-12 15:44:38 492

原创 [Array]442. Find All Duplicates in an Array

题目:题目分析: 容易看出题目函数要求算出数组中重复出现两次的数字,且返回对象也为数组。 对算法的要求上,时间复杂度要控制在O(n),也就是说排除了对每个元素进行单独检验的途径。此外,利用先排序处理再统计的方法也显得臃肿,因此在这里考虑采用利用一次遍历统计各元素出现的次数,最后在对统计结果为2的结果进行输出。初始化一个数组N,下标对应元素值,初始化为0,每遍历一...

2017-02-28 14:38:03 356

原创 [Array]495. Teemo Attacking

题目:题目分析: 题目要求根据给出的“(升序)攻击时间序列”以及“持续时间”算出Ashe的总中毒时间。 若在序列出给出的每个时间段没有重复部分,那么显而易见总时间就是序列的size与duration的积,所以这道题目的关键点在于分析若时间段存在重合的时候如何处理累加值的问题。解决方法如下: 方法一:避开对重复段的讨论。创建一个规模为timeSeries...

2017-02-26 16:45:06 348

原创 [Array]485. Max Consecutive Ones

题目:题目分析: 很显然题目的要求是让程序分析一个01数组中连续出现最多1的个数。那么简单的方法就是以遍历整个数组的形式统计出现最多的1的个数。关键变量: count:用于统计每组连续1的个数; MAX:用于统计count的最大值并在函数尾返回。代码完成:要点: ①主干思路为遍历到1开始统计,遍历到0结束统计并处理统计...

2017-02-26 13:48:15 286

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除