- 博客(259)
- 收藏
- 关注
原创 LeetCode 684. Redundant Connection
In this problem, a tree is anundirectedgraph that is connected and has no cycles.The given input is a graph that started as a tree with N nodes (with distinct values 1, 2, ..., N), with one additi...
2019-11-16 22:24:51
290
原创 mysql使用存储过程插入数据(不要在循环中提交事务)
delimiter $$create procedure load2(count int unsigned)begin declare s int unsigned default 1; declare c char(80) default repeat('a',80); while s<=count do insert into t1 select null,c;...
2019-11-02 11:34:00
1139
原创 cGlib使用
深入理解Java虚拟机,第二章第58页用到了cGlib。下载cGLib jar包,http://www.java2s.com/Code/Jar/c/Downloadcglib222jar.htm下载asm jar包,http://www.java2s.com/Code/Jar/o/Downloadorgobjectwebasm310v200803061910jar.htm注意,上...
2019-10-02 20:45:50
385
原创 LeetCode 417. Pacific Atlantic Water Flow
Given anm x nmatrix of non-negative integers representing the height of each unit cell in a continent, the "Pacific ocean" touches the left and top edges of the matrix and the "Atlantic ocean" touch...
2019-09-28 22:13:55
179
原创 LeetCode 241. Different Ways to Add Parentheses
Given a string of numbers and operators, return all possible results from computing all the different possible ways to group numbers and operators. The valid operators are+,-and*.Example 1:In...
2019-09-24 19:18:00
167
原创 计算在网格中从原点到特定点的最短路径长度
[[1,1,0,1], [1,0,1,0], [1,1,1,1], [1,0,1,1]]题目描述:1 表示可以经过某个位置,求解从 (0, 0) 位置到 (tr, tc) 位置的最短路径长度。采用bfs方法:import java.util.*;public class ShortestPath { public static void main(St...
2019-09-18 20:13:53
819
原创 LeetCode 665. Non-decreasing Array
Given an array withnintegers, your task is to check if it could become non-decreasing by modifyingat most1element.We define an array is non-decreasing ifarray[i] <= array[i + 1]holds for e...
2019-09-10 21:52:05
120
原创 LeetCode 763.Partition Labels
A stringSof lowercase letters is given. We want to partition this string into as many parts as possible so that each letter appears in at most one part, and return a list of integers representing th...
2019-09-10 21:41:14
155
原创 LeetCode547. Friend Circles
There areNstudents in a class. Some of them are friends, while some are not. Their friendship is transitive in nature. For example, if A is adirectfriend of B, and B is adirectfriend of C, then ...
2019-09-10 20:43:36
150
原创 233. Number of Digit One
Given an integer n, count the total number of digit 1 appearing in all non-negative integers less than or equal to n.Example:Input: 13Output: 6 Explanation: Digit 1 occurred in the following nu...
2019-08-09 15:56:57
159
原创 pytorch 多gpu训练, 单cpu测试
虽然一般是继续使用gpu测试,但是可能还是会有这种需求的时候# original saved file with DataParallelcheckpoint = "checkpoints/{}_best_loss.pth.tar".format(model_name)best_model = torch.load(checkpoint)state_dict = best_mo...
2019-08-03 16:37:25
2829
1
原创 剑指offer的一道题 调整数组顺序使奇数位于偶数前面
题目描述输入一个整数数组,实现一个函数来调整该数组中数字的顺序,使得所有的奇数位于数组的前半部分,所有的偶数位于数组的后半部分,并保证奇数和奇数,偶数和偶数之间的相对位置不变。这道题中要求奇数在前半部分,偶数在后半部分,同时还要具有稳定性。首先,如果这题不要求具有稳定性,那么可以很简单的做到 inplace的 O(n)时间复杂度public void reOrder(...
2019-08-01 14:42:04
143
原创 pytorch遇到的两个小问题
问题一:pytorch中 tensor如果变成了布尔值,那么相当于uint8。此时,需要显式的将tensor float化问题二:网络定义的时候,卷积等模块最好统一定义在init函数中。这样的话一句model.cuda()就可以将模型放到gpu上...
2019-07-24 22:38:22
188
原创 Jacarrd index(IOU) 和 dice coefficient的计算
两者都是常用的语义分割问题的评价指标Jacarrd index也就是IOU,即人们常说的交并比Jacarrd index: |A andB| / |A or B| = TP/(TP+FP+FN)dicecoefficient: 2*|A and B| / ( |A|+|B| ) = 2TP/(TP+FP+TP+FN) = 2TP/(2TP+FP+FN)即...
2019-07-17 20:02:09
1662
原创 反卷积,以pytorch为例
反卷积原理https://www.jianshu.com/p/fb50fe44a1a3反卷积大小计算https://www.jianshu.com/p/01577e86e506对于stride=1的情况比较简单,反卷积输出大小是固定的。对于stride>1的情形,反卷积输出大小有多种可能,通过output padding参数确定。stride>1时,...
2019-07-12 12:33:29
651
原创 LeetCode 207. Course Schedule 210. Course Schedule II
207There are a total ofncourses you have to take, labeled from0ton-1.Some courses may have prerequisites, for example to take course 0 you have to first take course 1, which is expressed as a...
2019-07-09 11:53:38
155
原创 LeetCode 23. Merge k Sorted Lists
Mergeksorted linked lists and return it as one sorted list. Analyze and describe its complexity.Example:Input:[ 1->4->5, 1->3->4, 2->6]Output: 1->1->2->3->4-...
2019-07-08 19:50:46
167
原创 124. Binary Tree Maximum Path Sum
Given anon-emptybinary tree, find the maximum path sum.For this problem, a path is defined as any sequence of nodes from some starting node to any node in the tree along the parent-child connectio...
2019-07-08 19:22:17
153
原创 61. Rotate List
Given a linkedlist, rotate the list to the right bykplaces, wherekis non-negative.Example 1:Input: 1->2->3->4->5->NULL, k = 2Output: 4->5->1->2->3->NULLExplan...
2019-07-04 14:55:29
145
原创 231. Power of Two
Given an integer, write a function to determine if it is a power of two.Example 1:Input: 1Output: true Explanation: 20= 1Example 2:Input: 16Output: trueExplanation: 24= 16Example 3:...
2019-06-28 20:46:51
112
转载 43. Multiply Strings
Given two non-negative integersnum1andnum2represented as strings, return the product ofnum1andnum2, also represented as a string.Example 1:Input: num1 = "2", num2 = "3"Output: "6"Exampl...
2019-06-26 20:06:33
112
原创 16. 3Sum Closest
Given an arraynumsofnintegers and an integertarget, find three integers innumssuch that the sum is closest totarget. Return the sum of the three integers. You may assume that each input would ...
2019-06-26 16:48:53
92
原创 14. Longest Common Prefix
Write a function to find the longest common prefix string amongst an array of strings.If there is no common prefix, return an empty string"".Example 1:Input: ["flower","flow","flight"]Output:...
2019-06-23 18:54:01
90
原创 LeetCode 125. Valid Palindrome
Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.Note:For the purpose of this problem, we define empty string as valid palindrome.Examp...
2019-06-23 18:48:21
92
原创 387. First Unique Character in a String
Given a string, find the first non-repeating character in it and return it's index. If it doesn't exist, return -1.Examples:s = "leetcode"return 0.s = "loveleetcode",return 2.Note:You ...
2019-06-23 11:28:41
108
原创 LeetCode 292. Nim Game
You are playing the following Nim Game with your friend: There is a heap of stones on the table, each time one of you take turns to remove 1 to 3 stones. The one who removes the last stone will be the...
2019-06-16 11:54:47
111
原创 LeetCode 138. Copy List with Random Pointer
A linked list is given such that each node contains an additional random pointer which could point to any node in the list or null.Return adeep copyof the list.Example 1:Input:{"$id":"1...
2019-06-12 15:41:08
79
原创 LeetCode 116. Populating Next Right Pointers in Each Node
You are given aperfect binary treewhereall leaves are on the same level, and every parent has two children. The binary tree has the following definition:struct Node { int val; Node *left; ...
2019-06-10 16:51:51
102
原创 LeetCode 91. Decode Ways
A message containing letters fromA-Zis being encoded to numbers using the following mapping:'A' -> 1'B' -> 2...'Z' -> 26Given anon-emptystring containing only digits, determine t...
2019-06-10 15:38:04
108
原创 LeetCode 54. Spiral Matrix
Given a matrix ofmxnelements (mrows,ncolumns), return all elements of the matrix in spiral order.Example 1:Input:[ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8, 9 ]]Output: [1,2,3,6,9,8,7,4,5]...
2019-06-10 14:57:57
98
原创 LeetCode 912. Sort an Array
Given an array of integersnums, sort the array in ascending order.Example 1:Input:[5,2,3,1]Output: [1,2,3,5]Example 2:Input: [5,1,1,2,0,0]Output: [0,0,1,1,2,5]Note:1 <= A....
2019-06-10 12:06:52
404
原创 LeetCode 127. Word Ladder
Given two words (beginWordandendWord), and a dictionary's word list, find the length of shortest transformation sequence frombeginWordtoendWord, such that:Only one letter can be changed at a ti...
2019-06-04 10:22:30
158
原创 LeetCode 227. Basic Calculator II
Implement a basic calculator to evaluate a simple expression string.The expression string contains onlynon-negativeintegers,+,-,*,/operators and empty spaces. The integer division should trun...
2019-06-03 16:34:33
186
原创 LeetCode 103. Binary Tree Zigzag Level Order Traversal
Given a binary tree, return thezigzag level ordertraversal of its nodes' values. (ie, from left to right, then right to left for the next level and alternate between).For example:Given binary tre...
2019-06-03 15:09:14
99
原创 LeetCode 394. Decode String
Given an encoded string, return it's decoded string.The encoding rule is:k[encoded_string], where theencoded_stringinside the square brackets is being repeated exactlyktimes. Note thatkis gua...
2019-06-02 15:30:42
121
原创 LeetCode 236. Lowest Common Ancestor of a Binary Tree
Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree.According to thedefinition of LCA on Wikipedia: “The lowest common ancestor is defined between two nodes p...
2019-06-02 14:37:33
97
原创 LeetCode 208. Implement Trie (Prefix Tree)
Implement a trie withinsert,search, andstartsWithmethods.Example:Trie trie = new Trie();trie.insert("apple");trie.search("apple"); // returns truetrie.search("app"); // returns fals...
2019-06-01 19:12:01
97
原创 LeetCode 148. Sort List
Sort a linked list inO(nlogn) time using constant space complexity.Example 1:Input: 4->2->1->3Output: 1->2->3->4Example 2:Input: -1->5->3->4->0Output: -1-...
2019-06-01 16:30:48
92
原创 LeetCode 102. Binary Tree Level Order Traversal
Given a binary tree, return thelevel ordertraversal 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 / \ 9 20 ...
2019-06-01 14:48:13
112
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人