- 博客(40)
- 收藏
- 关注
原创 LeetCode263 Ugly Number
Write a program to check whether a given number is an ugly number.Ugly numbers arepositive numberswhose prime factors only include2, 3, 5.Example 1:Input: 6Output: trueExplanation: 6 = 2 ×...
2019-05-29 21:09:11 83
原创 Anaconda 安装的虚拟环境不能使用CUDA
在Anaconda的base环境中,torch.cuda.is_available()函数是true,但是转为自己创建的虚拟环境后变为false;具体原因尚未找到,但是可以通过下面操作进行更正:操作前:torch.load(model_file)操作后:torch.load(model_file, map_location='cpu')...
2019-05-14 09:47:11 5877 6
原创 第2章
作业1问题描述答案6位状态位,3位控制位。各自功能如下:状态位:进位标位CF:当运算结果的最高位有进位或借位时,进位标志置1,CF=1;否则CF=0;零标志ZF:若运算结果为0,则ZF=1;否则ZF=0;符号标志SF:若运算结果最高位为1,则SF=1;否则SF=0;奇偶标志PF:当运算结果最低字节中“1”的个数为偶数时,PF=1;否则PF=0;溢出标志O...
2019-05-11 12:21:52 1645
原创 第1章
作业1问题描述答案 原始数据 十进制 十六进制 八进制 101011101.11011 349.84375 15d.d8 535.66 11100011001.011 1817.375...
2019-05-11 12:01:21 1205
原创 LeetCode260. Single Number III
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-05-10 21:40:16 82
原创 LeetCode258. 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. ...
2019-05-10 20:28:45 89
原创 LeetCode257. Binary Tree Paths
Given a binary tree, return all root-to-leaf paths.Note:A leaf is a node with no children.Example:Input: 1 / \2 3 \ 5Output: ["1->2->5", "1->3"]Explanation: All roo...
2019-05-10 20:12:21 56
原创 LeetCode242. Valid Anagram
Given two stringssandt, write a function to determine iftis an anagram ofs.Example 1:Input: s = "anagram", t = "nagaram"Output: trueExample 2:Input: s = "rat", t = "car"Output: fal...
2019-05-09 20:35:25 95
原创 LeetCode241. 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-05-08 16:18:28 102
原创 LeetCode240. 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-05-08 15:43:35 76
原创 LeetCode239. Sliding Window Maximum
Given an arraynums, there is a sliding window of sizekwhich is moving from the very left of the array to the very right. You can only see theknumbers in the window. Each time the sliding window m...
2019-05-07 22:50:47 83
原创 LeetCode238. Product of Array Except Self
Given an arraynumsofnintegers wheren> 1, return an arrayoutputsuch thatoutput[i]is equal to the product of all the elements ofnumsexceptnums[i].Example:Input: [1,2,3,4]Output: [...
2019-05-07 21:54:20 85
原创 LeetCode237. Delete Node in a Linked List
Write a function to delete a node (except the tail) in a singly linked list, given only access to that node.Given linked list --head =[4,5,1,9], which looks like following:Example 1:Inpu...
2019-05-07 21:35:15 114
原创 identifier NULL is undefined
在VS中,如果我们不使用任何标准头文件的话会出现这个bug。解决方案很简单,在文件中添加一个STL文件就可以了,如下:#include<vector>
2019-05-07 21:14:44 4603
原创 LeetCode236. 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-05-07 20:19:22 51
原创 LeetCode235. Lowest Common Ancestor of a Binary Search Tree
Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST.According to thedefinition of LCA on Wikipedia: “The lowest common ancestor is defined between ...
2019-05-07 16:57:45 116
原创 LeetCode234. Palindrome Linked List
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-05-06 16:52:51 53
原创 LeetCode233. 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-05-06 16:17:47 109
原创 LeetCode232. Implement Queue using Stacks
Implement the following operations of a queue using stacks.push(x) -- Push element x to the back of queue. pop() -- Removes the element from in front of queue. peek() -- Get the front element....
2019-05-05 21:03:09 77
原创 LeetCode231. 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-05-05 00:34:51 55
原创 Pytorch无法安装原因之无语
其实,科学上网除了可以提升自己的知识水平外,还可以帮你安装Pytorch。。。 当不能科学上网时: 当可以科学上网时: 当然,需要将你的代理设置为全局模式。 所以当你发现不能在线安装pytorch时,说不定是因为科学上网的问题。。。...
2019-05-03 09:27:12 2870
原创 LeetCode230. Kth Smallest Element in a BST
Given a binary search tree, write a functionkthSmallestto find thekth smallest element in it.Note:You may assume k is always valid, 1 ≤ k ≤ BST's total elements.Example 1:Input: root = [3,...
2019-05-03 09:07:05 177
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人