- 博客(20)
- 收藏
- 关注
原创 移除所有载有违禁货物车厢所需的最少时间(递归超时)
class Solution { public int minimumTime(String s) { Map<String,Integer> minStepNumMap = new HashMap<>(); return calMinStepNum(s,minStepNumMap); } public static int calMinStepNum(String s,Map<String,Integer&g.
2022-02-08 18:29:39
92
原创 前中后序遍历二叉树(递归实现)
void search(root,res){if(root == null){return;}res.add(root.val);search(root.left,res);search(root.right,res);}
2022-02-07 11:02:56
296
原创 二叉树前中后序遍历(循环实现)
前序遍历class Solution { public List<Integer> preorderTraversal(TreeNode root) { List<Integer> res = new ArrayList<>(); Stack<Integer> stack = new Stack<>(); while(root != null || !stack.isE
2022-02-07 10:58:22
405
原创 二叉树的后序遍历
/** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode() {} * TreeNode(int val) { this.val = val; } * TreeNode(int val, TreeNode left, TreeNode right) { .
2022-01-29 14:36:49
304
原创 maven配置 The JAVA_HOME environment variable is not defined correctly错误
当你对环境变量进行修改之后,一定要重新打开一个cmd窗口,此时测试mvn --version才会成功。这个坑,,,真的是太坑了。
2020-04-01 17:26:47
241
原创 leetcode——报数
def countAndSay(self, n: int) -> str: str0='1' if n==1: return '1' for i in range(n-1): num=1 if len(str0)==1: str0='11'...
2019-07-26 10:20:38
106
原创 leetcode:实现strStr()
class Solution: def strStr(self, haystack: str, needle: str) -> int: if needle=='': return 0 elif len(needle)>len(haystack): return -1 for i ...
2019-07-24 10:04:27
94
原创 leetcode:移除元素
class Solution: def removeElement(self, nums: List[int], val: int) -> int: remove_index=0 while(remove_index<len(nums)): if nums[remove_index]==val: ...
2019-07-24 09:50:26
75
原创 CodeBlock无法断点调试的解决方案
更新:最完美的解决方案:直接下载VS2017 OR 2019,放弃这个辣鸡编译器吧。(1)不是一个project而是单独cpp文件(2)project的路径包含中文或空格(3)编译时没有打开-g标志,导致没有debug信息。settings--》complier flags--》勾选produce debugging symbols[-g](4)gbd.exe的版本跟编译器版...
2019-04-03 15:41:25
2131
1
原创 剑指offer——Python:删除链表中重复的节点
class Solution: def deleteDuplication(self, pHead): # write code here if not pHead: return pHead start=ListNode(0) start.next=pHead result=star...
2019-03-18 10:51:21
554
原创 剑指offer——Python:链表中环的入口
class Solution: def EntryNodeOfLoop(self, pHead): # write code here #思路:存储每一个访问的节点,一旦下一节点与存储的节点相同,则意味着下一节点是环的入口 if not pHead: return None dic={} ...
2019-03-17 21:58:29
146
原创 剑指offer——Python:数组中的逆序对数
# -*- coding:utf-8 -*-class Solution: def InversePairs(self, data): # write code here #思路每次循环找出最小值,最小值的坐标 便是与当前最小值配队的逆序数,然后将当前最小值删掉 #但是,Python这样写,超时了 if not data ...
2019-03-15 11:12:37
600
原创 剑指offer——Python:孩子们的游戏
# -*- coding:utf-8 -*-class Solution: def LastRemaining_Solution(self, n, m): # write code here if not n or not m or n<1 or m<1: return -1 start=0 ...
2019-03-14 16:32:37
517
原创 剑指offer——Python:数组中第一个重复的数字
# -*- coding:utf-8 -*-class Solution: # 这里要特别注意~找到任意重复的一个值并赋值到duplication[0] # 函数返回True/False def duplicate(self, numbers, duplication): # write code here if not numbers ...
2019-03-14 16:01:34
514
原创 剑指offer——Python:1+2+3+...+n
# -*- coding:utf-8 -*-class Solution: def Sum_Solution(self, n): # write code here if not n or n<=0: return 0 sum=n+self.Sum_Solution(n-1) return s...
2019-03-14 15:07:52
250
原创 剑指offer——Pyhton:扑克牌顺子
# -*- coding:utf-8 -*-class Solution: def IsContinuous(self, numbers): # write code here #思路:如果5张牌中 除了0之外有重复的数字则直接返回False #记录牌中除0之外的最大值和最小值:如果扑克牌中除了0之外的其他数字的最大、最小值之差大于4则返...
2019-03-14 14:45:28
131
原创 剑指offer——Python:和为S的两个数字
# -*- coding:utf-8 -*-class Solution: def FindNumbersWithSum(self, array, tsum): # write code here #思路:用头尾两个指针i,j,如果对应数字之和小于目标值,i+=1,反之j-=1 #如果相等,则比较乘积是否小于上一次的乘积,若小于,则对乘积...
2019-03-14 10:29:12
183
原创 剑指offer——Python:第一个只出现一次的字符
# -*- coding:utf-8 -*-class Solution: def FirstNotRepeatingChar(self, s): # write code here #先使用字典存储每一个字母出现的次数以及第一次出现的位置 #用一个列表按出现顺序存储第一次出现的字母 #然后对列表中的字母挨个进行判断...
2019-03-12 19:14:32
243
原创 Win10系统下Tensorflow-gpu1.6.0版安装踩坑实录(安装环境CUDA9.0+cundnn)
首先给大家梳理一下TensorFlow1.6.0版本的安装步骤:1、安装CUDA9.02、安装cudnn3、安装TensorFlow-gpu1.6.0Part I 安装CUDA首先,确定你要安装的CUDA版本一定要与TensorFlow版本对应,否则后面安装TensorFlow会报错。其他的TensorFlow版本我不清楚,但是1.5.0及1.6.0的TensorFlow与...
2018-11-09 16:37:07
3297
原创 Pyrhon:删除排序链表中的重复元素II
题目:给定一个排序链表,删除所有含有重复数字的节点,只保留原始链表中 没有重复出现 的数字。示例 1:输入: 1->2->3->3->4->4->5输出: 1->2->5示例 2:输入: 1->1->1->2->3输出: 2->3 # Definition for singly-...
2018-11-09 11:32:54
119
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人