算法
文章平均质量分 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 · 375 阅读 · 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 · 383 阅读 · 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 · 697 阅读 · 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 · 6170 阅读 · 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 · 182 阅读 · 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 · 130 阅读 · 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 · 343 阅读 · 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 · 152 阅读 · 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 · 153 阅读 · 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 · 131 阅读 · 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 · 119 阅读 · 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 · 144 阅读 · 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 · 109 阅读 · 0 评论 -
两数相加,不用加减乘除
写一个函数,求两个整数之和,要求在函数体内不得使用+、-、*、/四则运算符号。相加从二进制的角度理解:和为异或结果,如果与运算结果左移为0则输出结果,否则相加的和和与运算向左移继续执行以上。class Solution: def Add(self, num1, num2): while num2!=0: temp=num1^num2 ...原创 2019-02-25 17:22:32 · 329 阅读 · 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 · 172 阅读 · 0 评论 -
开放问题
top k问题一般采用hash统计频率,再来使用堆排序,如果有内存大小限制,则采用分堆的思想,对数字使用比特位,对字符使用hash值除以一个值来分堆,这样相同的元素都在一个堆里面。...原创 2019-07-07 17:23:21 · 205 阅读 · 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 · 143 阅读 · 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 · 544 阅读 · 0 评论 -
修桌子
Arthur最近搬到了新的别墅,别墅特别大,原先的桌子显得比较小,所以他决定换一张新的桌子。他买了一张特别大的桌子,桌子是由很多条桌腿进行支撑的,可是回到家之后他发现桌子不稳,原来是桌子腿长度不太相同。他想要自己把桌子修理好,所以他决定移除掉一些桌腿来让桌子变得平稳。桌子腿总共有n条腿,第i条腿长度为li,Arthur移除第i桌腿要花费代价为di。假设k条腿桌子平稳的条件:超过一半桌腿能够达...原创 2019-03-25 13:25:23 · 350 阅读 · 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 · 130 阅读 · 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 · 97 阅读 · 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 · 149 阅读 · 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 · 243 阅读 · 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 · 158 阅读 · 0 评论 -
Print linked list in reverse order
Recursionclass Solution: # 返回从尾部到头部的列表值序列,例如[1,2,3] def printListFromTailToHead(self, listNode): # write code here if listNode: return self.printListFromTailToHe...原创 2019-02-19 00:18:51 · 232 阅读 · 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 · 474 阅读 · 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 · 150 阅读 · 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 · 135 阅读 · 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 · 99 阅读 · 0 评论 -
算法之编程语言
文章目录引用、指针列表、元组is和==引用、指针列表、元组区别:元组不可变,列表可变,元组比列表更安全列表不可作为字典的键,元组可以元组占用内存更小,比列表操作跟快is和==python对象三要素:id、type、valueis比较的是id,即是否为同一对象,位于同一地址,==比较的是值,对于...原创 2019-02-16 00:47:56 · 1588 阅读 · 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 · 150 阅读 · 0 评论 -
算法总结之机器学习
文章目录Logistics RegressionSVMSVM和LR异同Decision TreeEnsemble LearningBagging—Random ForestBoostingAdaboostGBDTXGBoostLogistics Regression推倒SVMSVM和LR异同仅讨论线性SVM相同:都是线性分类器不同:(1) LR边界由所有样本决定,而SVM的边界是由支...原创 2019-02-15 21:24:35 · 218 阅读 · 0 评论 -
算法总结之深度学习
文章目录深度网络CNNResNetDensNetVGGBatch Normalization梯度弥散、梯度爆炸RNN、LSTM目标检测RCNNFast RCNNFaster RCNNYOLOSSD深度网络CNNResNet问题:当网络加深,学习效果很差动机:在已存在的浅层网络上加入很多恒等映射层,这样能保证学习效果不差于千层网络,受此启发,提出ResNet解释:(1) 保证信息流动。当...原创 2019-02-15 18:46:35 · 718 阅读 · 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 · 162 阅读 · 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 · 162 阅读 · 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 · 121 阅读 · 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 · 126 阅读 · 0 评论 -
Reconstruct binary tree
输入某二叉树的前序遍历和中序遍历的结果,请重建出该二叉树。假设输入的前序遍历和中序遍历的结果中都不含重复的数字。例如输入前序遍历序列{1,2,4,7,3,5,6,8}和中序遍历序列{4,7,2,1,5,3,8,6},则重建二叉树并返回。Recursion is used to solve this problemclass Solution: # 返回构造的TreeNode根节点 ...原创 2019-02-19 00:09:11 · 526 阅读 · 0 评论 -
之字形打印二叉树
请实现一个函数按照之字形打印二叉树,即第一行按照从左到右的顺序打印,第二层按照从右至左的顺序打印,第三行按照从左到右的顺序打印,其他行以此类推。类似于层次遍历,只是需要判断奇偶层,如果为偶数层则需要反序输出Common methodclass Solution: def Print(self, pRoot): # write code here i...原创 2019-02-24 00:01:08 · 489 阅读 · 0 评论 -
LeetCode 191: Number of 1 Bits
n & (n-1) can remove the last zero 1 in binary format.class Solution(object): def hammingWeight(self, n): """ :type n: int :rtype: int """ res = 0 ...原创 2019-02-28 00:12:51 · 163 阅读 · 0 评论
分享