算法
文章平均质量分 91
forever_zzx
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
搭建cuda环境
1 安装驱动1.1 前期工作1.1.1 禁用nouveauubuntu 16.04默认安装了第三方开源的驱动程序nouveau,安装nvidia显卡驱动首先需要禁用nouveau,不然会碰到冲突的问题,导致无法安装nvidia显卡驱动。指令如下sudo gedit/etc/modprobe.d/blacklist.conf 打开文件,在最后添加如下两行:blacklist nouveauoptions nouveau modeset=01.1.2 更新系统修改sudo u..原创 2021-02-06 19:45:44 · 416 阅读 · 0 评论 -
pytorch安装及faster-rcnn.pytorch使用记录
目前所处的办公环境限制较多,对搭建开发环境造成较大阻碍,在安装pytorch时, pip和conda库不能及时更新,很多时候需要手动安装。在这样的背景下,本文记录pytorch和faster-rcnn.pytorch 的在使用过程中的问题。1. pytorch的安装pytorch的安装首先需要确定安装的版本,其次要明确当前cuda的版本,最后还要知道所使用的python版本。一般来讲,如果使用官方库安装,安装的pytorch应该是在对应版本的cuda下编译的,但是由于本人所处的环境,pip和conda库原创 2020-10-13 11:21:45 · 421 阅读 · 1 评论 -
torchvision transform巨坑
最近用到torchvision.transform.Normalize,发现不同版本对输入的改变不同,下面对比torchvision 0.2.1和0.4.2版本0.2.1:def normalize(tensor, mean, std): """Normalize a tensor image with mean and standard deviation. See ``Normalize`` for more details. Args: tensor (Te原创 2020-08-24 15:28:39 · 726 阅读 · 0 评论 -
mmcv 安装记录
安装mmcv,我选择的是源码安装,按照官方给出的步骤,运行命令MMCV_WITH_OPS=1 pip install -e .出现错误提示,如下:distutils.errors.DistutilsError: Could not find suitable distribution for Requirement.parse(‘pytest-runner’)于是安装pytest-runner:pip install pytest-runner随后再次运行安装命令,仍然出现错误,于是原创 2020-07-18 14:55:55 · 6241 阅读 · 11 评论 -
LeetCode124 最大路径和
给定一个非空二叉树,返回其最大路径和。本题中,路径被定义为一条从树中任意节点出发,达到任意节点的序列。该路径至少包含一个节点,且不一定经过根节点。示例 1:输入: [1,2,3] 1 / \ 2 3输出: 6示例2:输入: [-10,9,20,null,null,15,7] -10/ \9 20/ ...原创 2019-10-19 22:13:24 · 207 阅读 · 0 评论 -
LeetCode 704: Binary Search
Solving this by using iteration and recursion methodRecursionclass Solution: def search(self, nums: 'List[int]', target: 'int') -> 'int': def recursion(nums, l, r): if l&...原创 2019-02-13 23:07:47 · 124 阅读 · 0 评论 -
LeetCode 108:Convert Sorted Array to Binary Search Tree
The Problem can be seen in Convert Sorted Array to Binary Search Tree,the analysis is shown in the following.A given array named as nums (like [-10,-3,0,5,9]) is sorted in ascending order.constructi...原创 2019-02-13 19:45:00 · 189 阅读 · 0 评论 -
LeetCode 33: Search in Rotated Sorted Array
This problem is little difference to LeetCode 81. Search in Rotated Sorted Array II. In this problem, it assumes that no duplicate exists in the array.Binary search is used to solve it. Iteration and...原创 2019-02-13 23:29:58 · 155 阅读 · 0 评论 -
LeetCode 81: Search in Rotated Sorted Array II
Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand.(i.e., [0,0,1,2,2,5,6] might become [2,5,6,0,0,1,2]).You are given a target value to search. If found in...原创 2019-02-14 00:01:34 · 146 阅读 · 0 评论 -
LeetCode 153: Find Minimum in Rotated Sorted Array
Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand.(i.e., [0,1,2,4,5,6,7] might become [4,5,6,7,0,1,2]).Find the minimum element.You may assume no dupli...原创 2019-02-14 00:47:04 · 156 阅读 · 0 评论 -
LeetCode 169: Majority Element
Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times.You may assume that the array is non-empty and the majority element alway...原创 2019-02-28 23:10:12 · 166 阅读 · 0 评论 -
LeetCode 229: Majority Element II
Given an integer array of size n, find all elements that appear more than ⌊ n/3 ⌋ times.Note: The algorithm should run in linear time and in O(1) space.Example 1:Input: [3,2,3]Output: [3]Example...原创 2019-02-28 23:23:15 · 171 阅读 · 0 评论 -
LeetCode 43: Multiply Strings (大数相乘)
Given two non-negative integers num1 and num2 represented as strings, return the product of num1 and num2, also represented as a string.Example 1:Input: num1 = "2", num2 = "3"Output: "6"Example 2..原创 2019-02-25 14:18:55 · 376 阅读 · 0 评论 -
LeetCode 2: Add Two Numbers
You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return i...原创 2019-02-25 16:12:24 · 142 阅读 · 0 评论 -
两数相加,不用加减乘除
写一个函数,求两个整数之和,要求在函数体内不得使用+、-、*、/四则运算符号。相加从二进制的角度理解:和为异或结果,如果与运算结果左移为0则输出结果,否则相加的和和与运算向左移继续执行以上。class Solution: def Add(self, num1, num2): while num2!=0: temp=num1^num2 ...原创 2019-02-25 17:22:32 · 356 阅读 · 0 评论 -
LeetCode 94: Binary Tree Inorder Traversal
Given a binary tree, return the inorder traversal of its nodes’ values.Example:Input: [1,null,2,3] 1 \ 2 / 3Output: [1,3,2]Iterationclass Solution: def inorderTraversal...原创 2019-02-20 13:20:27 · 188 阅读 · 0 评论 -
LeetCode 69: Sqrt(x)
Implement int sqrt(int x).Compute and return the square root of x, where x is guaranteed to be a non-negative integer.Since the return type is an integer, the decimal digits are truncated and only t...原创 2019-03-06 22:23:47 · 269 阅读 · 0 评论 -
LeetCode 198: House Robber
You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is that adjacent house...原创 2019-03-10 13:23:38 · 164 阅读 · 0 评论 -
LeetCode 213: House Robber II
You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed. All houses at this place are arranged in a circle. That means the first house is ...原创 2019-03-10 13:25:31 · 107 阅读 · 0 评论 -
LeetCode 290: Word Pattern
Given a pattern and a string str, find if str follows the same pattern.Here follow means a full match, such that there is a bijection between a letter in pattern and a non-empty word in str.Example ...原创 2019-03-15 17:17:22 · 148 阅读 · 0 评论 -
修桌子
Arthur最近搬到了新的别墅,别墅特别大,原先的桌子显得比较小,所以他决定换一张新的桌子。他买了一张特别大的桌子,桌子是由很多条桌腿进行支撑的,可是回到家之后他发现桌子不稳,原来是桌子腿长度不太相同。他想要自己把桌子修理好,所以他决定移除掉一些桌腿来让桌子变得平稳。桌子腿总共有n条腿,第i条腿长度为li,Arthur移除第i桌腿要花费代价为di。假设k条腿桌子平稳的条件:超过一半桌腿能够达...原创 2019-03-25 13:25:23 · 383 阅读 · 0 评论 -
有序数组的交集和并集
define two indexs starting from 0 for the arrays. Compare values the two indexs referring to, and move the indexs under each condition.The union of two sorted arraysdef union(list1, list2): l1...原创 2019-04-26 16:58:13 · 569 阅读 · 0 评论 -
字符串排列相关
All possible permutations of a stringdef permutation(prefix, s): if len(s) == 0: print(prefix) else: visit = set() for i in range(len(s)): if s[i] in vis...原创 2019-04-26 17:46:48 · 152 阅读 · 0 评论 -
开放问题
top k问题一般采用hash统计频率,再来使用堆排序,如果有内存大小限制,则采用分堆的思想,对数字使用比特位,对字符使用hash值除以一个值来分堆,这样相同的元素都在一个堆里面。...原创 2019-07-07 17:23:21 · 224 阅读 · 0 评论 -
LeetCode 53: Maximum Subarray
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: 6Explanation:...原创 2019-02-16 23:34:20 · 147 阅读 · 0 评论 -
LeetCode 325: Maximum Size Subarray Sum Equals k
Given an array nums and a target value k, find the maximum length of a subarray that sums to k. If there isn’t one, return 0 instead.Hashmap is also used in this problem. Iterate the array and calcul...原创 2019-02-15 14:45:49 · 192 阅读 · 0 评论 -
Leetcode 1: Two Sum
Given an array of integers, return indices of the two numbers such that they add up to a specific target.You may assume that each input would have exactly one solution, and you may not use the same e...原创 2019-02-15 15:23:52 · 192 阅读 · 0 评论 -
算法总结之深度学习
文章目录深度网络CNNResNetDensNetVGGBatch Normalization梯度弥散、梯度爆炸RNN、LSTM目标检测RCNNFast RCNNFaster RCNNYOLOSSD深度网络CNNResNet问题:当网络加深,学习效果很差动机:在已存在的浅层网络上加入很多恒等映射层,这样能保证学习效果不差于千层网络,受此启发,提出ResNet解释:(1) 保证信息流动。当...原创 2019-02-15 18:46:35 · 733 阅读 · 0 评论 -
算法总结之机器学习
文章目录Logistics RegressionSVMSVM和LR异同Decision TreeEnsemble LearningBagging—Random ForestBoostingAdaboostGBDTXGBoostLogistics Regression推倒SVMSVM和LR异同仅讨论线性SVM相同:都是线性分类器不同:(1) LR边界由所有样本决定,而SVM的边界是由支...原创 2019-02-15 21:24:35 · 256 阅读 · 0 评论 -
LeetCode 572: Subtree of Another Tree
Given two non-empty binary trees s and t, check whether tree t has exactly the same structure and node values with a subtree of s. A subtree of s is a tree consists of a node in s and all of this node...原创 2019-02-15 21:41:00 · 158 阅读 · 0 评论 -
算法之编程语言
文章目录引用、指针列表、元组is和==引用、指针列表、元组区别:元组不可变,列表可变,元组比列表更安全列表不可作为字典的键,元组可以元组占用内存更小,比列表操作跟快is和==python对象三要素:id、type、valueis比较的是id,即是否为同一对象,位于同一地址,==比较的是值,对于...原创 2019-02-16 00:47:56 · 1620 阅读 · 0 评论 -
LeetCode 268: Missing Number
Given an array containing n distinct numbers taken from 0, 1, 2, …, n, find the one that is missing from the array.Example 1:Input: [3,0,1]Output: 2Example 2:Input: [9,6,4,2,3,5,7,0,1]Output: 8...原创 2019-02-16 00:49:15 · 107 阅读 · 0 评论 -
LeetCode 448: Find All Numbers Disappeared in an Array
Given an array of integers where 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once.Find all the elements of [1, n] inclusive that do not appear in this array.Could ...原创 2019-02-16 20:41:06 · 147 阅读 · 0 评论 -
LeetCode 442: Find All Duplicates in an Array
Given an array of integers, 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once.Find all the elements that appear twice in this array.Could you do it without extra sp...原创 2019-02-16 20:47:24 · 160 阅读 · 0 评论 -
最大差值
有一个长为n的数组A,求满足0≤a≤b<n的A[b]-A[a]的最大值。给定数组A及它的大小n,请返回最大差值。测试样例:[10,5],2返回:0Greedy algorithm is used in this problem. The max difference is gotten in each step. max[i] = array[i] - minimum value...原创 2019-02-16 22:46:23 · 499 阅读 · 0 评论 -
LeetCode 718: Maximum Length of Repeated Subarray
Given two integer arrays A and B, return the maximum length of an subarray that appears in both arrays.Example 1:Input:A: [1,2,3,2,1]B: [3,2,1,4,7]Output: 3Explanation: The repeated subarray wi...原创 2019-02-16 23:20:47 · 135 阅读 · 0 评论 -
LeetCode 525: Contiguous Array
Given a binary array, find the maximum length of a contiguous subarray with equal number of 0 and 1.Using hashmap to solve it. Map<sum, index>, the hashmap only stores the sum of first (index +...原创 2019-02-15 14:18:46 · 197 阅读 · 0 评论 -
LeetCode 121: Best Time to Buy and Sell Stock
Say you have an array for which the ith element is the price of a given stock on day i.If you were only permitted to complete at most one transaction (i.e., buy one and sell one share of the stock), ...原创 2019-02-16 23:37:21 · 169 阅读 · 0 评论 -
LeetCode 26: Remove Duplicates from Sorted Array
Given a sorted array nums, remove the duplicates in-place such that each element appear only once and return the new length.Do not allocate extra space for another array, you must do this by modifyin...原创 2019-02-17 21:46:57 · 260 阅读 · 0 评论 -
LeetCode 3: Longest Substring Without Repeating Characters
Given a string, find the length of the longest substring without repeating characters.Example 1:Input: "abcabcbb"Output: 3 Explanation: The answer is "abc", with the length of 3. Example 2:Inpu...原创 2019-02-17 22:24:46 · 108 阅读 · 0 评论
分享