Question1(letecode)

Question: 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. Example: Given nums = [2, 7, 11, 15], target = 9, Because nums[0] +
分类: 其他 发布时间: 04-06 22:51 阅读次数: 0

任务二(letecode)

题目: Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M. For example, two is written as II in Roman numeral, just two one’s added together. Twelve is written as, XII, which is simply X + II. The number twenty seven is w
分类: 其他 发布时间: 04-06 22:51 阅读次数: 0

任务三(letecode)

Given a 32-bit signed integer, reverse digits of an integer. Example 1: Input: 123 Output: 321 Example 2: Input: -123 Output: -321 Example 3: Input: 120 Output: 21 class Solution { public: int reverse(int x) { int flag = 1; if(x < 0){ flag = -1;
分类: 其他 发布时间: 04-06 22:51 阅读次数: 0

任务四(letecode)

题目描述 在数组中的两个数字,如果前面一个数字大于后面的数字,则这两个数字组成一个逆序对。输入一个数组,求出这个数组中的逆序对的总数P。并将P对1000000007取模的结果输出。 即输出P%1000000007 输入描述: 题目保证输入的数组中没有的相同的数字数据范围: 对于%50的数据,size<=10^4 对于%75的数据,size<=10^5 对于%100的数据,size<=2*10^5 示例1 输入 复制 1,2,3,4,5,6,7,0 输出 复制 7 求数组中的逆序对的数量----
分类: 其他 发布时间: 04-06 22:51 阅读次数: 0

Python基础任务二

\1. 列表 a. 标志 b. 基本操作(创建,append( ),pop( ) ,del( ), 拷贝) c. 列表相关方法 \2. 元组 a. 标志 b. 基本操作(创建及不可变性) \3. string字符串 a. 定义及基本操作(+,*,读取方式) b. 字符串相关方法 \4. 字符串格式化问题 列表 列表可以完成大多数集合类的数据结构实现。列表中元素的类型可以不相同,它支持数字,字符串甚至可以包含列表(所谓嵌套)。 和字符串一样,list可以被索引和切片,List可以使用+操作符进行
分类: 其他 发布时间: 04-06 22:51 阅读次数: 0

任务五(letecode)

一、描述 Palindrome NumberEasy13161250FavoriteShareDetermine whether an integer is a palindrome. An integer is a palindrome when it reads the same backward as forward. Example 1: Input: 121 Output: true Example 2: Input: -121 Output: false Explanation:
分类: 其他 发布时间: 04-06 22:51 阅读次数: 0

Python基础任务三

1.dict字典 a. 定义 映射是一个按照任意值排序的对象组成的数据集合,这些任意值被称为键(key),字典是Python中唯一的映射类型,字典中的键可以是不同类型,值(value)是任意对象,并且可以是不同类型。 字典是用大括号{ }定义的,每个项目都是key:value形式。 b. 创建 字典由键(key)和对应值(value)成对组成。字典也被称作关联数组或哈希表。基本语法如下: dict = {‘Alice’: ‘2341’, ‘Beth’: ‘9102’, ‘Cecil’: ‘32
分类: 其他 发布时间: 04-06 22:51 阅读次数: 0

任务六(letecode)

题目: Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists. 思路: 思路很简单,遍历两个链表,每次取最小值。 代码: /** Definition for singly-linked list. struct ListNode { int val; ListNode
分类: 其他 发布时间: 04-06 22:51 阅读次数: 0

任务七(letecode)

题目 Given two binary trees, write a function to check if they are the same or not. Two binary trees are considered the same if they are structurally identical and the nodes have the same value. Example 1: Input: 1 1 / \ / 2 3 2 3 [1,2,3], [1,2,
分类: 其他 发布时间: 04-06 22:51 阅读次数: 0

人生苦短,Python太慢

1007 素数对猜想 (20 分) 让我们定义dn为:dn=pn+1−pn,其中pi是第i个素数。显然有d1=1,且对于n>1有dn是偶数。“素数对猜想”认为“存在无穷多对相邻且差为2的素数”。 现给定任意正整数N(<105),请计算不超过N的满足猜想的素数对的个数。 输入格式: 输入在一行给出正整数N。 输出格式: 在一行中输出不超过N的满足猜想的素数对的个数。 输入样例: 20 输出样例: 4 一样的解题方法用Python3写超时。。。 c++ 一遍过。。。。。。。。 Python3
分类: 其他 发布时间: 04-06 22:51 阅读次数: 0

1016

def tran(num, D): i = 0 n = 0 while num > 0: t = int(num % 10) if D == t: i = i + 1 n = n + D * 10 ** (i - 1) num = int(num / 10) return n A, Da, B, Db = map(int, input().split()) Pa = tran(A, Da) Pb = tran(B, Db) print(Pa + Pb)
分类: 其他 发布时间: 04-06 22:51 阅读次数: 0

Pytorch load深度模型时报错:RuntimeError: cuda runtime error (10) : invalid device ordinal

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/yinhui_zhang/article/details/86572232 问题背景和描述:   我是在服务器上用显卡2上训练我的模型,但是模型还在继续跑,所以我只能在其他显卡上重新做测试实验看效果的好坏。在pytorch上重新load训练好的深度学习模型时报错:RuntimeError: cuda runtime error (10) : invalid device ordinal at to
分类: 其他 发布时间: 04-06 22:51 阅读次数: 0

[python技巧]Linux终端下使用Python和tee命令

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/yinhui_zhang/article/details/86605444 问题背景: 在跑深度学习的情况下,需要在Linux终端下直接使用python命令来执行程序,但是我不仅想显示在屏幕上,还想把log文件保存到本地,来分析结果。这时候就需要用到Linux的管道命令和重定向命令tee来实现。 解决方案: 关于tee命令可以参考[1] [4],Python在终端的使用可以参考[2]。 pyt
分类: 其他 发布时间: 04-06 22:51 阅读次数: 0

配置深度学习环境重启后,Linux 用户登录界面死循环登入,一篇博客就够了。

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/yinhui_zhang/article/details/86606669 对,就是参考一篇博客就够了,网上其他都瞎bb。 reference: https://blog.csdn.net/ssmixi/article/details/73483795
分类: 其他 发布时间: 04-06 22:51 阅读次数: 0

Python3 函数中类型注解(Function Annotations)

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/yinhui_zhang/article/details/86629045 问题描述: def read_text(path: Path, encoding=None) -> str: """ Not Path.read_text for compatibility with Python 3.4. """ with path.open(encoding=enco
分类: 其他 发布时间: 04-06 22:51 阅读次数: 0

遍历二叉树,一篇博客就够了

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/yinhui_zhang/article/details/88558674 讲在前面的话,网上一搜遍历二叉树出来的结果真的是良莠不齐,简直不能忍啊,很多前序、中序、后序遍历分别用三个结构不一样的算法来描述,这谁能顶得住啊!!!遍历二叉树代码,看一篇博客就够了。 1.二叉树遍历分类:   一般我们二叉树分为前序、中序、后序遍历(说明:本文不包括层次遍历),假设用L、D、R分别表示遍历左子树、访问根节
分类: 其他 发布时间: 04-06 22:51 阅读次数: 0

Python实现八大经典排序算法

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/yinhui_zhang/article/details/88670313 1、写在前面的话 本篇博客并不涉及到排序算法的理论讲解,具体理论可以参考reference的链接,并且强烈推荐数据结构和算法的可视化网站【0】。本文给出八种经典的排序算法的Python实现代码和部分注解,算是一个总结,也感谢网络众多优秀的博主分享他们的idea,站在巨人的肩膀上果然成长很迅速。排序可以说在经典算法中是很重要
分类: 其他 发布时间: 04-06 22:51 阅读次数: 0

python实现字符串模式匹配KMP算法

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/yinhui_zhang/article/details/89060927 讲在前面的话,KMP算法是字符串中匹配的快速算法,时间复杂度为O(m+n) 。KMP算法的核心思想主要通过分析前面字符串的信息的来滑动匹配字符串,避免当不匹配时像传统匹配算法回溯到匹配字符串的开头,而当不匹配时如何滑动这个问题就是由next[j]数组来决定,而求next[j]数组的核心思想就是将匹配字符串互相错开一个位置来
分类: 其他 发布时间: 04-06 22:50 阅读次数: 0

Printing Python version in output

Printing Python version in output https://stackoverflow.com/questions/1252163/printing-python-version-in-output method1: python --version method 2: under python environment import sys print(sys.__version__) method 3: import platform print(platform.p
分类: 其他 发布时间: 04-06 22:50 阅读次数: 0

Ubuntu 代理设定

Ubuntu代理设定 System Settings -> Network -> Network proxy Method -> Manual HTTP Proxy HTTPS Proxy FTP Proxy Socks Host
分类: 其他 发布时间: 04-06 22:50 阅读次数: 0