求最大连续子序列和的 N 中方法
def max_continuous_subsequence(l):
maxsofar = 0
length = len(l)
for i in range(length):
for j in range(i, length):
# -*-coding:UTF-8-*- | |
import six | |
class Field(object): | |
def __init__(self, key, default=None): | |
self.key = key | |
class BaseMapper(type): | |
def __new__(cls, name, bases, attrs): |
import java.util.Arrays; | |
public class TimSortTest { | |
public static void main(String[] args) { | |
int arr[] = {3, 6, 8, 9, 15, 13, 11, 7, 42, 58, 100, 22, 26, 39, 38, 43, 50, | |
70, 46, 10, 36, 56, 58, 56, 59, 10, 71, 89,46, 10, 36, 56, 58, 56, 59, 10, 71, 89}; | |
System.out.println("before sort: " + Arrays.toString(arr)); | |
System.out.println("array length: " + arr.length); | |
TimSort.sort(arr, 0, arr.length, null, 0, 0); |
def binary_search(l, t): | |
low, high = -1, len(l) | |
while low+1 != high: | |
mid = (low + high) / 2 | |
if l[mid] < t: | |
low = mid | |
else: | |
high = mid | |
pos = high | |
if pos >= len(l) or l[pos] != t: |
# ip source https://db-ip.com/db/#downloads | |
import csv | |
import netaddr | |
result = [] | |
with open('dbip-country-2017-05.csv', 'r') as rf, \ | |
open('ip-cidr-CN', 'w') as wf: | |
reader = csv.reader(rf, delimiter=',') | |
for row in reader: |
import platform | |
import time | |
import sys | |
import binascii | |
import marshal | |
import dis | |
import struct | |
def view_pyc_file(path): |
class LRUCache: | |
""" LRUCache implemented with HashMap and LinkList | |
>>> cache = LRUCache(3) | |
>>> cache.set(1,1) | |
>>> cache.set(2,2) | |
>>> cache.set(3,3) | |
>>> cache | |
capacity: 3 [(1, 1), (2, 2), (3, 3)] | |
>>> cache.get(1) | |
1 |
def longest_substring(str1, str2): | |
""" | |
>>> longest_substring("apple pie available", "apple pies") | |
'apple pie' | |
>>> longest_substring("apples", "appleses") | |
'apples' | |
>>> longest_substring("bapples", "cappleses") | |
'apples' | |
""" | |
result = "" |
# 修改默认 shell | |
set-option -g default-shell /bin/zsh | |
# 启用终端 256 色 | |
set -g default-terminal "screen-256color" | |
# 状态栏编码 | |
set -g status-utf8 on | |
# 状态栏前景色背景色 | |
set -g status-fg white | |
set -g status-bg cyan | |
# 状态栏高亮 |