原创 Python slice notation [:] - leetcode 189. Rotate Array

1. a[start:stop:step] q = "12345" w = q[0:2:1] # [0, 2) print(f"w: {w}") # w: 12 w = q[::-1] # if step is negative

原创 python 模塊導入注意事項

入口文件不能使用相對導入。 import .module1 if __name__ == '__main__': print("hello") ImportError: attempted relative impor

原创 gdb debug summary

   gdb attach program gdb -p $(pidof rcpd)  gdb use symbol gdb att 2271 -s cips_app.sym  gdb create struct params (gdb

原创 mini program for suna 接口文檔

API 2019.8.10. http://18.220.98.204:80/suna/index 自測結果 “微信開發者工具”中允許使用ip地址測試的設置方法如下: 2019.8.15. post api tes

原创 sort & search algorithm

def quick_sort(array): if len(array) < 2: return array else: pivot_index = 0 pivot

原创 unit test & mock

external_module.py def multiply(x, y): return x*y+1 main.py import unittest from unittest import mock from un

原创 算法-動態規劃2

    5年前寫過一篇關於動態規劃的博客。最近重新學習基本算法,對動態規劃有了更深入的體會。 對於“揹包問題”,現在可以按照自己的思路寫出來代碼了,雖然運行一下發現有問題,經過修改調試,最終可以完成。這樣的過程,我認爲比記住一些代

原创 my docker tutorial

0 what’s docker docker instruction article I created an docker image which installed ubuntu, ssh, python2&3, pipenv

原创 算法-動態規劃3

根據在算法-動態規劃2裏提到的思路,讓我們來解決一個組合問題 :leetcode 第77題。 0 問題描述 給定2個整數n,k,求出從[1,…,n]中取k個數字的所有組合。 例如 n=4, k=2 就是從[1,2,3,4]中取2個

原创 slide window & +Counter() : leetcode 438. Find All Anagrams in a String

Find All Anagrams in a String Input: s: “cbaebabacd” p: “abc” Output: [0, 6] Explanation: The substring with star

原创 yqzj微信公衆號&小程序開發

1. 《微信開發入門》文檔中 list = [token, timestamp, nonce] list.sort() sha1 = hashlib.sha1

原创 subsets : zero left padding : leetcode 78

leetcode 78 求解序列的所有子集。 例如: [1, 2, 3]. 所有子集爲:[ [ ], [1], [2], [3], [1, 2], [1, 3], [2, 3], [1, 2, 3] ] 其中一種解題思路爲:

原创 regular expression examples

import re a = "java|Python|c0123tttyyyuu9" res = re.search("java\|Python\|c([0-9]+)tttyyyuu9", a) print(res.group(

原创 backtrace&usage of slice notation[:] - leetcode 77. Combinations

def combine(self, n: int, k: int) -> List[List[int]]: """ Input: n = 4, k = 2 Output:

原创 build tree & sum path (usage of list[0]) - 404. Sum of Left Leaves

from collections import deque class TreeNode: def __init__(self, val=0, left=None, right=None): self.va