Skip to content

Instantly share code, notes, and snippets.

View lttzzlll's full-sized avatar

liutaotao lttzzlll

  • http://metasota.ai/
View GitHub Profile
@lttzzlll
lttzzlll / quick_sort.py
Created April 18, 2018 02:26
quick sort
import random
def partation(ints, low, high):
pivot = ints[random.choice(range(low, high + 1))]
while low <= high:
while ints[low] < pivot:
low += 1
while pivot < ints[high]:
high -= 1
@lttzzlll
lttzzlll / interview_python2.md
Last active May 7, 2018 09:24
python interview

Python面试攻略(嗨谈篇) 2018-04-13 DataCastle DataCastle数据城堡

写在前面

千呼万唤始出来,咱们需要的面试文档终于整理出来啦!这一次,DC君为大家送上的python面试题之基础概念篇。通过对十几份面试题目的整理,DC君选出了其中出现频率最高的十个题目,附上答案供各位小伙伴参考!

@lttzzlll
lttzzlll / insert_sort.py
Last active April 16, 2018 07:37
insert sort
import random
def insert_sort(ints):
n = len(ints)
for i in range(1, n):
if ints[i] >= ints[i - 1]:
continue
tmp = ints[i]
while i > 0 and tmp < ints[i - 1]:
@lttzzlll
lttzzlll / select_sort.py
Last active April 16, 2018 07:38
select sort
import random
def select_sort(ints):
n = len(ints)
for i in range(0, n - 1):
minPos = i
for j in range(i + 1, n):
if ints[j] < ints[minPos]:
minPos = j
@lttzzlll
lttzzlll / bubble_sort.py
Last active April 16, 2018 07:38
bubble sort
import random
def bubble_sort(ints):
n = len(ints)
for j in range(0, n - 1):
flag = False
for i in range(0, n - 1 - j):
if ints[i] > ints[i + 1]:
flag = True
@lttzzlll
lttzzlll / word_freq.py
Created April 12, 2018 08:00
cout word frequency
import re
import sys
from collections import Counter
def read(path):
pat = re.compile(r'\s+')
with open(path, encoding='utf-8') as f:
for line in f:
for word in pat.split(line.rstrip()):
re_word = word.strip(r'\"').strip(r"\'")
"""
ENV: Python3, pandas pip3 install pands or pip install pandas
"""
import pandas as pd
import sys
import os
from datetime import datetime
@lttzzlll
lttzzlll / python_interview2.md
Last active May 7, 2018 13:02
interview about python backend

Python语法以及其他基础部分

1.可变与不可变类型;

不可变(immutable)对象类型
  • int
  • float
  • decimal
  • complex
  • bool
@lttzzlll
lttzzlll / reverse_single_linkedlist.py
Created April 9, 2018 05:54
single linked list reverse
class Node:
__slots__ = ('val', 'next')
def __init__(self, val):
self.val = val
self.next = None
def reverse(head):
if head:
@lttzzlll
lttzzlll / process_wave.py
Created April 9, 2018 03:18
process wave file seq
import sys
import re
import os
import subprocess
CMD = r'\\ccpsofsep\am_s2\users\kskumar\Tools\sox\sox.exe {0} -e ms-adpcm {1}'
def read(path):
pat = re.compile(r'\s+')