- 博客(517)
- 收藏
- 关注
原创 【环境配置】Ubuntu系统下GPU驱动、CUDA、cuDNN和Pytorch安装
Ubuntu系统下GPU驱动、CUDA、cuDNN版本对应关系及安装过程
2022-02-28 16:29:18
7508
原创 【剑指offer】链表找环的入口
给一个链表,若其中包含环,请找出该链表的环的入口结点,否则,输出null。解题思路:在链表判环的基础上进行优化追击问题,一快一慢可以再环中相遇 p1=p1.next; p2=p2.next.next那么如何找到环的入口针对一快一慢的节点,慢节点走的路成为s,则快的为2s,当两节点在环中环绕n圈2s = s + nc对于慢节点 s = a + x两式子结合...
2020-04-18 17:08:02
373
原创 【Python】pandas合并多个CSV表,去重表头
我们有三个子表,每个表都有表头但是没有每行的索引,每一个表在csv文件中结构如下:name,agex,65y,77z,10通过Pandas打开 data = pd.read_csv(r'test.csv'),默认会加上行索引,并且第一行为列索引 name age0 x 651 y 772 z 10data = pd.read_cs...
2020-04-04 11:58:29
10404
7
原创 【剑指offer】栈的压入、弹出序列(Python中List模拟栈队列操作)
题目描述输入两个整数序列,第一个序列表示栈的压入顺序,请判断第二个序列是否可能为该栈的弹出顺序。假设压入栈的所有数字均不相等。例如序列1,2,3,4,5是某栈的压入顺序,序列4,5,3,2,1是该压栈序列对应的一个弹出序列,但4,3,5,1,2就不可能是该压栈序列的弹出序列。(注意:这两个序列的长度是相等的)Python总List的栈和队列使用栈操作入栈为 stack.append(...
2020-04-01 10:35:17
366
原创 【剑指offer】数字在排序数组中出现的次数
统计一个数字在排序数组中出现的次数。解题思路:遍历查找不是本题的最优解,既然给出的是有序数组,所以我们只需要找到目标的左侧和右侧的索引即可。所以我们可以找到本数组当中key+0.5和key-0.5的位置即可得到次数,二分查找将减少时间复杂度。代码# -*- coding:utf-8 -*-class Solution: def GetIdx(self, data, k)...
2020-03-26 15:24:14
207
原创 【Leetcode】342. Power of Four(二进制计算)(判定是否为4的幂次方)
Given an integer (signed 32 bits), write a function to check whether it is a power of 4.Example 1:Input: 16Output: trueExample 2:Input: 5Output: false题目大意:给出一个int类型的数,判定是否为4的幂次方;解题思...
2019-10-07 15:40:10
257
原创 [LeetCode]1138. Alphabet Board Path(第147周周赛)(模拟)
On an alphabet board, we start at position (0, 0), corresponding to characterboard[0][0].Here, board = ["abcde", "fghij", "klmno", "pqrst", "uvwxy", "z"].We may make the following moves:'U' mov...
2019-07-28 14:04:37
276
原创 【Leetcode】455. Assign Cookies(贪心思想)
Assume you are an awesome parent and want to give your children some cookies. But, you should give each child at most one cookie. Each child i has a greed factor gi, which is the minimum size of a coo...
2019-07-27 15:16:01
183
原创 【Leetcode】524. Longest Word in Dictionary through Deleting(最长子序列)
Given a string and a string dictionary, find the longest string in the dictionary that can be formed by deleting some characters of the given string. If there are more than one possible results, retur...
2019-07-23 10:20:00
355
原创 【Leetcode】680. Valid Palindrome II(回文字符串)
Given a non-empty strings, you may deleteat mostone character. Judge whether you can make it a palindrome.Example 1:Input: "aba"Output: TrueExample 2:Input: "abca"Output: TrueExpla...
2019-07-21 10:17:04
318
原创 【Leetcode】378. Kth Smallest Element in a Sorted Matrix(第k个大的数)(容器)
Given a n x n matrix where each of the rows and columns are sorted in ascending order, find the kth smallest element in the matrix.Note that it is the kth smallest element in the sorted order, not t...
2019-07-16 15:39:29
149
原创 【Leetcode】1123. Lowest Common Ancestor of Deepest Leaves(二叉树最深叶子结点的公共父节点)
Given a rooted binary tree, return the lowest common ancestor of its deepest leaves.Recall that:The node of a binary tree is aleafif and only if it has no children Thedepthof the root of the ...
2019-07-14 18:56:07
1144
原创 【Leetcode】454. 4Sum II(算法时间复杂度)
Given four lists A, B, C, D of integer values, compute how many tuples(i, j, k, l)there are such thatA[i] + B[j] + C[k] + D[l]is zero.To make problem a bit easier, all A, B, C, D have same lengt...
2019-07-14 09:58:22
249
原创 【Leetcode】1109. Corporate Flight Bookings(第144周周赛)(线段树模版题)
There arenflights, and they are labeledfrom1ton.We have a list of flight bookings. Thei-th bookingbookings[i] = [i, j, k]means that we bookedkseats from flights labeleditojinclusive....
2019-07-11 20:12:29
242
原创 【Leetcode】350. Intersection of Two Arrays II(求解数组的交集)
Given two arrays, write a function to compute their intersection.Example 1:Input: nums1 = [1,2,2,1], nums2 = [2,2]Output: [2,2]Example 2:Input: nums1 = [4,9,5], nums2 = [9,4,9,8,4]Output:...
2019-07-08 23:21:20
166
原创 【Leetcode】347. Top K Frequent Elements(C++容器理解)(优先队列)
Given a non-empty array of integers, return the k most frequent elements.Example 1:Input: nums = [1,1,1,2,2,3], k = 2Output: [1,2]Example 2:Input: nums = [1], k = 1Output: [1]Note: Yo...
2019-07-06 17:01:42
286
原创 【Leetcode】300. Longest Increasing Subsequence(最大上升子序列)
Given an unsorted array of integers, find the length of longest increasing subsequence.Example:Input: [10,9,2,5,3,7,101,18]Output: 4 Explanation: The longest increasing subsequence is [2,3,7,10...
2019-07-05 20:25:06
174
原创 【Leetcode】295. Find Median from Data Stream(取当前输入数组的中位数)(优先队列)
Median is the middle value in an ordered integer list. If the size of the list is even, there is no middle value. So the median is the mean of the two middle value.For example,[2,3,4], the median ...
2019-06-29 19:20:38
196
原创 【Leetcode】287. Find the Duplicate Number(查找数组中唯一一组相同数字)(单链表判环)
Given an arraynumscontainingn+ 1 integers where each integer is between 1 andn(inclusive), prove that at least one duplicate number must exist. Assume that there is only one duplicate number, fi...
2019-06-19 16:43:56
240
原创 [leetcode] 279. Perfect Squares(DP)(平方数)
Given a positive integer n, find the least number of perfect square numbers (for example, 1, 4, 9, 16, ...) which sum to n.Example 1:Input: n =12Output: 3 Explanation: 12 = 4 + 4 + 4.Example ...
2019-06-18 19:18:33
198
原创 【Leetcode】1091. Shortest Path in Binary Matrix(第141周周赛)(搜索+优先队列)
In an N by N square grid, each cell is either empty (0) or blocked (1).Aclearpath from top-left to bottom-righthas lengthkif and only if it is composed of cellsC_1, C_2, ..., C_ksuch that:A...
2019-06-16 14:50:31
435
原创 【Leetcode】1090. Largest Values From Labels(第141周周赛)(选择排序sort)
We have a set of items: thei-th item has valuevalues[i]and labellabels[i].Then, we choosea subsetSof these items, such that:|S| <= num_wanted For every labelL, the number of items inS...
2019-06-16 14:44:30
206
原创 【Leetcode】1089. Duplicate Zeros(第141周周赛)(模拟)
Given a fixed lengtharrayarrof integers, duplicate each occurrence of zero, shifting the remaining elements to the right.Note that elements beyond the length of the original array are not written...
2019-06-16 14:36:42
490
原创 【Leetcode】274. H-Index(水平面上的最大正方形)
Given an array of citations (each citation is a non-negative integer) of a researcher, write a function to compute the researcher's h-index.According to thedefinition of h-index on Wikipedia: "A sc...
2019-06-14 21:25:17
155
原创 【Leetcode】264. Ugly Number II(DP)(规律)
Write a program to find then-th ugly number.Ugly numbers arepositive numberswhose prime factors only include2, 3, 5.Example:Input: n = 10Output: 12Explanation: 1, 2, 3, 4, 5, 6, 8, 9, 10,...
2019-06-13 20:12:20
158
原创 【Leetcode】260. Single Number III(map字典)
Given an array of numbersnums, in which exactly two elements appear only once and all the other elements appear exactly twice. Find the two elements that appear only once.Example:Input: [1,2,1,...
2019-06-12 18:56:11
141
原创 【Leetcode】258. Add Digits(数学)
Given a non-negative integernum, repeatedly add all its digits until the result has only one digit.Example:Input: 38Output: 2 Explanation: The process is like: 3 + 8 = 11, 1 + 1 = 2. Since 2 ...
2019-06-10 19:07:37
156
原创 【Leetcode】1079. Letter Tile Possibilities(第140周赛)(字符串全排列)
You have a set oftiles, where each tile has one lettertiles[i]printed on it. Return the number of possible non-empty sequences of letters you can make.Example 1:Input: "AAB"Output: 8Expl...
2019-06-09 14:45:49
469
原创 【Leetcode】1078. Occurrences After Bigram(第140周赛)(字符串处理)
Given wordsfirstandsecond, consider occurrences in sometextof the form "first second third", wheresecondcomes immediately afterfirst, andthirdcomes immediately aftersecond.For each such o...
2019-06-09 14:34:36
248
原创 【Leetcode】240. Search a 2D Matrix II(思维)
Write an efficient algorithm that searches for a value in anmxnmatrix. This matrix has the following properties:Integers in each row are sorted in ascending from left to right. Integers in each...
2019-06-07 20:22:51
152
原创 【Leetcode】234. Palindrome Linked List(BN的递归)(判断回文链表)
Given a singly linked list, determine if it is a palindrome.Example 1:Input: 1->2Output: falseExample 2:Input: 1->2->2->1Output: trueFollow up:Could you do it in O(n) time a...
2019-06-04 15:07:44
208
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人