随笔分类 - Python
摘要:# Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # self.right = None # 递归,中序遍
阅读全文
摘要:#用二分查找法class Solution(object): def searchRange(self, nums, target): """ :type nums: List[int] :type target: int :rtype: List[int] """ first = 0 last =
阅读全文
摘要:# 递归方法解决class Solution(object): def letterCombinations(self, digits): """ :type digits: str :rtype: List[str] """ d = {"2":"abc", "3":"def", "4":"ghi"
阅读全文
摘要:class Solution(object): def isValid(self, s): """ :type s: str :rtype: bool """ stack = [] #存放符号 d = {"]": "[", ")":"(", "}":"{"} “”“ 判断符号是否是结束符号,如果是,
阅读全文
摘要:class Solution(object): def lengthOfLongestSubstring(self, s): """ :type s: str :rtype: int """ usedchar = {} #存储无重复得字符 max_length = start = 0 #初始化最长字
阅读全文
摘要:一、冒泡排序 冒泡排序动图演示 二、选择排序 动态图 三、插入排序 从第一个元素开始,该元素可以认为已经被排序; 取出下一个元素,在已经排序的元素序列中从后向前扫描; 如果该元素(已排序)大于新元素,将该元素移到下一位置; 重复步骤3,直到找到已排序的元素小于或者等于新元素的位置; 将新元素插入到该
阅读全文
摘要:Given a linked list, swap every two adjacent nodes and return its head. Example: Note: Your algorithm should use only constant extra space. You may no
阅读全文
摘要:Given a singly linked list, group all odd nodes together followed by the even nodes. Please note here we are talking about the node number and not the
阅读全文
摘要:Given a singly linked list L: L0→L1→…→Ln-1→Ln,reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→… You may not modify the values in the list's nodes, only nodes its
阅读全文
摘要:Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity. Example:
阅读全文
摘要:# Definition for singly-linked list. # class ListNode(object): # def __init__(self, x): # self.val = x # self.next = None class Solution(object): def partition(self, head, x):...
阅读全文
摘要:#!/usr/bin/python # -*- coding: UTF-8 -*- from pythonds.basic.stack import Stack def parChecker(symbolString): s = Stack() balanced = True index = 0 w
阅读全文
摘要:1.安装python2 下载地址: https://www.python.org/downloads/windows/ 进入页面,下拉,64位系统要选择这个。 下载完成后,一直点击下一步,直到安装完毕。 2.配置Python2环境变量 (1) 右键点击"计算机",然后点击"属性" (2) 然后点击"
阅读全文
摘要:1.PyCharm 配置远程python解释器和在本地修改服务器代码 2.PyCharm设置仿sublime配色__Py版本2018.1
阅读全文
摘要:Given a sorted linked list, delete all duplicates such that each element appear only once. Example 1: Input: 1->1->2 Output: 1->2 Example 2: Input: 1-
阅读全文
摘要:本项目使用卷积神经网络识别字符型图片验证码,其基于 TensorFlow 框架。它封装了非常通用的校验、训练、验证、识别和调用 API,极大地减低了识别字符型验证码花费的时间和精力。 项目地址: https://github.com/nickliqian/cnn_captcha 操作系统: 环境部署
阅读全文
摘要:Python版本升级 CentOS 6.3自带的Python版本为2.6,首先需要升级到2.7版本。由于旧版本的Python已被深度依赖,所以不能卸载原有的Python,只能全新安装。 1.下载Python-2.7.4.tgz 2. 解压安装,命令如下: 3. 创建链接来使系统默认python变为p
阅读全文
摘要:由于题目说了有且只有唯一解,可以考虑两遍扫描求解:第一遍扫描原数组,将所有的数重新存放到一个dict中,该dict以原数组中的值为键,原数组中的下标为值;第二遍扫描原数组,对于每个数nums[i]查看target-nums[i]是否在dict中,若在则可得到结果。 当然,上面两遍扫描是不必要的,一遍
阅读全文
摘要:python版本:
阅读全文

浙公网安备 33010602011771号