原创 第三章--字典與集合

第三章–字典與集合 本章內容的大綱如下: • 常見的字典方法 • 如何處理查找不到的鍵 • 標準庫中 dict 類型的變種 • set 和 frozenset 類型 • 散列表的工作原理 • 散列表帶來的潛在影響(什麼樣的數據類型

原创 第二章--序列構成的數組

第二章–序列構成的數組 2.1 python內置序列類型 按存儲類型來分 容器系列 list、tuple、collections.deque 能存放不同類型的數據 扁平系列 str、bytes、bytearray、memory

原创 《流暢的python》概述

《流暢的python》概述 《流暢的python》適合有一定python開發經驗的人進階使用,它並非python使用手冊、而是會強調python的獨有特性,重點會講述python的語言核心跟基本庫。 書本分爲六個主題 介紹pyt

原创 第一章--python數據模型

第一章–python數據模型 這一章主要介紹了python的特殊函數的使用和注意事項,特殊函數即內置的以‘__’爲開頭結尾的函數 collections.namedtuple用於構造只有少數屬性但沒有方法的對象,類似於c語言中的

原创 python的內存管理算法與優化

python的內存管理算法與優化 前期準備 我們可以用python的gc模塊控制python的內存管理和回收 gc.disable()# 暫停自動垃圾回收 gc.collect()# 執行完整的垃圾回收,返回無法到達的對象的數

原创 55 Jump Game

# 55 Jump Game題目來源:https://leetcode.com/problems/jump-game/description/題意分析:給定一個正整數列表,每個數字num表示可以從數字的位置往後num步,開始在第一個數字,

原创 213 House Robber

# 213 House Robber題目來源:https://leetcode.com/problems/house-robber-ii/description/題意分析:給定一個正整數列表,列表頭尾相連成環,要求不能取相鄰的正整數,輸出

原创 639. Decode Ways II

#639. Decode Ways II題目來源:https://leetcode.com/problems/decode-ways-ii/description/題意分析:存在一個映射把"A"-"Z"映射到1-26。給定一串包含數字喝和

原创 23. Merge k Sorted Lists

# 23. Merge k Sorted Lists題目來源:https://leetcode.com/problems/merge-k-sorted-lists/description/ 題意分析:合併K個有序鏈表爲一個有序鏈表 Exa

原创 python作業之numpy

import numpy as np import scipy from scipy.linalg import toeplitz def compute(A,B,num,m): I=np.eye(m) numI=num*I re

原创 120 Triangle

# 120 Triangle題目來源:https://leetcode.com/problems/triangle/description/題意分析:給定一個三角形,找到一條使經過數值之和最小的從頂到下的路徑,每次只能移動到下一層相鄰的結

原创 134 Gas Station

# 134 Gas Station題目來源: https://leetcode.com/problems/gas-station/description/題意分析:有N個氣站圍成了圈,每個氣站有gas[i],你有一輛車可以從任一氣站出發,

原创 92. Reverse Linked List II

#92. Reverse Linked List II92. Reverse Linked List題目來源:https://leetcode.com/problems/reverse-linked-list-ii/description

原创 84. Largest Rectangle in Histogram

#84. Largest Rectangle in Histogram(求矩形最大面積)題目來源:https://leetcode.com/problems/largest-rectangle-in-histogram/descripti

原创 4. Median of Two Sorted Arrays

題目鏈接https://leetcode.com/problems/median-of-two-sorted-arrays/description/題目描述There are two sorted arrays nums1 and num