This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def lisArray(arr, n): | |
""" | |
returns a array of LIS | |
""" | |
dp = [[arr[0]]] | |
for i in range(1, n): | |
temp = 0 | |
tempSubArray = [] | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Solution(object): | |
def maxIncreaseKeepingSkyline(self, grid): | |
""" | |
:type grid: List[List[int]] | |
:rtype: int | |
""" | |
colMax = [0] * len(grid[0]) | |
rowMax = [] | |
for i in grid: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#再windos按鈕畫面點擊右鍵(並按下執行) | |
#先在cmd 命令提示字元 輸入python再輸入import this | |
#將那段話存入 xxx.txt | |
from collections import Counter #記住從from 甚麼 import 甚麼都要放在第一行 以免篩選器錯誤 | |
fin=open('xxx.txt','rt') | |
s=fin.read().lower() #物件fin 使用函式read一次讀取所有內容, 使用函式lower將所有字母轉換小寫 | |
words=re.findall(r'[\w\']+',s) #用re.findall找出大小寫字母、數字、底線、和單引號 | |
c=Counter(words) #將物件counter以words為輸入, 將獲得的counter物件轉換成c | |
print(c.most_common(5)) #把c內容最常出現的五個屬性字找出 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Pickling | |
import pickle | |
# An arbitrary collection of objects supported by pickle. | |
data = { | |
'a': [1, 2.0, 3, 4+6j], | |
'b': ("character string", b"byte string"), | |
'c': {None, True, False} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from tkinter import * | |
from tkinter.colorchooser import askcolor | |
class Paint(object): | |
DEFAULT_PEN_SIZE = 5.0 | |
DEFAULT_COLOR = 'black' | |
def __init__(self): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import sys, os | |
import base64 | |
token = "X-Attachment-Id" | |
def print_usage(): | |
print( "Usage: exatt.py [OPTION] EMAIL_FILES" ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
import sys | |
import signal | |
from os import system | |
### MENU ### | |
# Here are all the elements you can import | |
# Box elements |