自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(45)
  • 收藏
  • 关注

原创 数据预处理(json-->csv)

1.通过json读取文件现在,我们将探索将JSON数据转换为表格格式。 在nobel-laureates.json中,我们拥有900多位诺贝尔奖获得者的数据。 让我们加载它,看看:nobel_laureates = json.load(open("data/nobel-laureates.json", "r"))pprint(nobel_laureates["laureates"][:2])输出如下:[{'born': '1845-03-27', 'bornCity': 'Lennep (

2020-11-11 01:24:45 539 1

原创 数据预处理(csv-->json)

对于csv文件数据的预处理过程1. csv文件读取并转换成列表存储首先,我们将讨论从CSV文件中获取数据并将其转换为以JSON格式存储。 我们有一个示例CSV文件colors.csv,其中包含一些有关颜色的数据。 加载并打印内容时,我们可以看到每行对应一种颜色,并包含ID,颜色名称,该颜色的十六进制代码以及该颜色的红色,绿色和蓝色值 用于RGB代码。import csv, jsonfrom pprint import pprintreader = csv.reader(open("./data/

2020-11-10 22:55:40 682

原创 算法等零碎知识梳理

算法的五大特性高效性、可读性、有穷性、健壮性、可行性。可行性: 最通俗的理解就是,他可以运行,原则上可以精确运行。有穷性: 也叫有限性, 指能够在有限的步骤中运行结束,避免死循环。高效性: 算法运行的要足够快,效率高, 当然这就是优化问题了。可读性: 源代码可以让正常人看懂。健壮性: 安全性要好,不会被轻易破坏。也就是即使有问题的输入它也能做出一定处理。分块查找分块查找(索引顺序表查找)子集树子集树是一个数学学科词汇,属于函数类,当所给问题是从n个元素的集合S中找出S满足某种性质的子集

2020-07-06 01:57:52 893

原创 E-R模型与UML简介

什么是E-R模型?E-R模型(Entity-Relationship model)。描述实体信息之间关系的一种模型。例如高级概念模型(high-level conceptual model)。利用这种高级概念模型,可以建立很多逻辑模型,例如XML等等。ER模型是图形表示法,我们可以将其几乎通过算法转换为关系(表驱动)模型。E-R模型和UML关系?首先介绍ER 方法学的表示法。目前,ER 建模中使用了数种表示法,包括陈氏 ER、Barker ER Information Engineering (IE

2020-07-02 01:01:50 1614

原创 计算机视觉Image processing

Image Processing:1.image filtering: change range of image(可以理解为将图片的pixel范围变小,即颜色光彩度变低)g(x) = t(f(x))2.image warping: change domain of imageg(x) = f(t(x))point processiong:The simplest kind of ra...

2020-04-24 08:29:01 1925 4

原创 【力扣】121. 买卖股票的最佳时机

题目描述:给定一个数组,它的第 i 个元素是一支给定股票第 i 天的价格。如果你最多只允许完成一笔交易(即买入和卖出一支股票一次),设计一个算法来计算你所能获取的最大利润。注意:你不能在买入股票前卖出股票。例子:示例 1:输入: [7,1,5,3,6,4]输出: 5解释: 在第 2 天(股票价格 = 1)的时候买入,在第 5 天(股票价格 = 6)的时候卖出,最大利润 = 6-1 ...

2020-04-14 04:02:35 125

原创 【力扣】119. 杨辉三角 II Python3解法

题目描述:给定一个非负索引 k,其中 k ≤ 33,返回杨辉三角的第 k 行。例子:示例:输入: 3输出: [1,3,3,1]思路:和上一个杨辉三角 I解法没区别,只不过是最后输出最后一个元素列表。代码:class Solution: def getRow(self, rowIndex: int) -> List[int]: mat = [[]]*...

2020-04-14 03:47:09 298

原创 【力扣】118. 杨辉三角 python3解法

题目描述:给定一个非负整数 numRows,生成杨辉三角的前 numRows 行。在杨辉三角中,每个数是它左上方和右上方的数的和。例子:list = [[1],[1,1],[1,2,1],[1,3,3,1],[1,4,6,4,1]]思路:我们先建个 数组: 每行长度递增 , 每行的每个元素为1list = [[1],[1,1],[1,1,1],[1,1,1,1],...

2020-04-14 03:18:08 457 1

原创 【力扣】111. 二叉树的最小深度 Python3解法

题目描述:给定一个二叉树,找出其最小深度。最小深度是从根节点到最近叶子节点的最短路径上的节点数量。说明: 叶子节点是指没有子节点的节点。例子:给定二叉树 [3,9,20,null,null,15,7], 3 / \ 9 20 / \ 15 7返回它的最小深度 2.思路:递归方法:分为四种情况:1.当前节点为空,返回0,表示不算当前这一...

2020-04-09 07:16:00 272

原创 【力扣】110. 平衡二叉树 Python3解法

题目描述:给定一个二叉树,判断它是否是高度平衡的二叉树。本题中,一棵高度平衡二叉树定义为:一个二叉树每个节点 的左右两个子树的高度差的绝对值不超过1。例子:示例 1:给定二叉树 [3,9,20,null,null,15,7] 3 / \ 9 20 / \ 15 7返回 true 。示例 2:给定二叉树 [1,2,2,3,3,null,nu...

2020-04-09 01:00:12 241

原创 【LeetCode】107. Binary Tree Level Order Traversal II Python3解法

题目描述:Given a binary tree, return the bottom-up level order traversal of its nodes’ values. (ie, from left to right, level by level from leaf to root).例子:For example:Given binary tree [3,9,20,null,...

2020-04-07 03:09:31 113

原创 【LeetCode】104. Maximum Depth of Binary Tree Python3解法

题目描述:Given a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.Note: A leaf is a node with no chi...

2020-04-07 01:17:51 222

原创 【LeetCode】101. Symmetric Tree Python3解法

题目描述:Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tree [1,2,2,3,4,4,3] is symmetric: 1 / \ 2 2 / \ / \3 4 4 3...

2020-04-07 00:30:30 129

原创 【LeetCode】100. Same Tree Python3解法

题目描述: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.例子:...

2020-04-06 22:34:41 129

原创 【LeetCode】88. Merge Sorted Array Python3解法

题目描述:Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array.Note:The number of elements initialized in nums1 and nums2 are m and n respectively.You may assume ...

2020-04-06 05:07:53 163

原创 【LeetCode】83. Remove Duplicates from Sorted List Python3解法

题目描述:Given a sorted linked list, delete all duplicates such that each element appear only once.例子:Example 1:Input: 1->1->2Output: 1->2Example 2:Input: 1->1->2->3->3Output...

2020-04-06 03:32:18 184

原创 【LeetCode】70. Climbing Stairs python3解法

题目描述:You are climbing a stair case. It takes n steps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?Note: Given n will be a posi...

2020-04-06 02:48:50 219

原创 【LeetCode】69. Sqrt(x) Python3解法

题目描述:Implement int sqrt(int x).Compute and return the square root of x, where x is guaranteed to be a non-negative integer.Since the return type is an integer, the decimal digits are truncated and ...

2020-04-04 08:24:11 140

原创 【LeetCode】67. Add Binary Python3解法

题目描述:Given two binary strings, return their sum (also a binary string).The input strings are both non-empty and contains only characters 1 or 0.例子:Example 1:Input: a = "11", b = "1"Output: "100"...

2020-04-04 06:24:21 102

原创 【LeetCode】66. Plus One Python3解法

题目描述:Given a non-empty array of digits representing a non-negative integer, plus one to the integer.The digits are stored such that the most significant digit is at the head of the list, and each el...

2020-04-04 02:12:23 163

原创 【LeetCode】58. Length of Last Word Python3解法

题目描述:Given a string s consists of upper/lower-case alphabets and empty space characters ’ ', return the length of last word (last word means the last appearing word if we loop from left to right) in ...

2020-04-03 08:51:29 108

原创 【LeetCode】53. Maximum Subarray Python3解法

题目描述:Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum.例子:Example:Input: [-2,1,-3,4,-1,2,1,-5,4],Output: 6Ex...

2020-04-03 02:32:10 178

原创 【LeetCode】38. Count and Say Python3解法

题目描述:The count-and-say sequence is the sequence of integers with the first five terms as following:1112112111112211 is read off as “one 1” or 11.11 is read off as “two 1s” or ...

2020-04-03 01:01:57 176

原创 【LeetCode】35. Search Insert Position Python3解法

题目描述:Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.You may assume no duplicates in the arr...

2020-04-02 21:35:02 134

原创 【LeetCode】28. Implement strStr() Python3解法

题目描述:Return the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.例子:Example 1:Input: haystack = "hello", needle = "ll"Output: 2Example 2:Input: hays...

2020-04-02 20:52:55 91

原创 【LeetCode】27. Remove Element Python3解法

题目描述:Given an array nums and a value val, remove all instances of that value in-place and return the new length.Do not allocate extra space for another array, you must do this by modifying the input...

2020-04-02 05:21:05 129

原创 【LeetCode】26. Remove Duplicates from Sorted Array Python3解法

题目描述:Given a sorted array nums, remove the duplicates in-place such that each element appear only once and return the new length.Do not allocate extra space for another array, you must do this by mo...

2020-04-02 03:56:52 150

原创 【LeetCode】21. Merge Two Sorted Lists Python3解法

题目描述: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.例子:Example:Input: 1->2->4, 1->3->4Out...

2020-04-02 02:46:48 86

原创 【LeetCode】20. Valid Parentheses Python3解法

题目描述:Given a string containing just the characters ‘(’, ‘)’, ‘{’, ‘}’, ‘[’ and ‘]’, determine if the input string is valid.An input string is valid if:Open brackets must be closed by the same type ...

2020-04-02 01:44:56 86

原创 【LeetCode】14. Longest Common Prefix Python3解法

题目描述: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"]O...

2020-04-01 05:10:21 200

原创 【LeetCode】13. Roman to Integer Python3解法

题目描述:Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M.Symbol ValueI 1V 5X 10L 50C 100D ...

2020-04-01 03:10:45 173

原创 【LeetCode】9. Palindrome Number Python3解法

题目描述:Determine whether an integer is a palindrome. An integer is a palindrome when it reads the same backward as forward.例子:Example 1:Input: 121Output: trueExample 2:Input: -121Output: false...

2020-04-01 00:28:50 146

原创 【LeetCode】7. Reverse Integer Python3解法

题目描述:Given a 32-bit signed integer, reverse digits of an integer.Note:Assume we are dealing with an environment which could only store integers within the 32-bit signed integer range: [−231, 231 −...

2020-03-31 23:50:03 70

原创 【LeetCode】5. Longest Palindromic Substring Python3解法

题目描述:Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000.例子:Input: “babad”Output: “bab”Note: “aba” is also a valid answer.思路:遍历每一个...

2020-03-31 09:17:50 132

原创 【LeetCode】 3. longest substring without repeating characters Python3解法

题目描述:Given a string, find the length of the longest substring without repeating characters.例子:Input: “abcabcbb”Output: 3Explanation: The answer is “abc”, with the length of 3.思路1:暴力解法首先计算出strin...

2020-03-31 03:30:44 179

原创 【LeetCode】2. Add Two Numbers Python3解法

题目描述:You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and re...

2020-03-31 00:37:40 205

原创 【LeetCode】1.TwoSum Python3解法

题目描述: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, and you may not use the ...

2020-03-30 23:49:22 188

原创 关于python基础语法的一些基础问题(循环与判断)

第一题 输入一个数,判断它是否能被3或5或7整除number = input("请输入数:")number= int(number)if number % 3 == 0: print("此数能被3整除")else: print("此数无法被3整除")if number % 7 == 0: prin

2019-03-06 16:14:51 751

原创 python解决哲学家就餐问题(死锁问题)

#哲学家就餐(解决死锁问题)import threading,timerlock1 = threading.RLock()rlock2 = threading.RLock()rlock3 = threading.RLock()rlock4 = threading.RLock()rlock5 = threading.RLock()class Zhexuejia(): def _...

2019-02-28 16:00:24 3985 5

原创 实例说明python中join()和daemon()作用

当一个进程启动之后,会默认产生一个主线程,因为线程是程序执行流的最小单元,当设置多线程时,主线程会创建多个子线程,在python中,默认情况下(其实就是setDaemon(False)),主线程执行完自己的任务以后,就退出了,此时子线程会继续执行自己的任务,直到自己的任务结束当我们使用setDaemon(True)方法,设置子线程为守护线程时,主线程一旦执行结束,则全部线程全部被终止执行,可能...

2019-02-28 15:40:35 627

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除