摘要:
无中间变量交接两变量值 class Solution: def jiaohuan(self, a, b): a = a ^ b b = a ^ b a = a ^ b return a, b if __name__ == "__main__": s = Solution() a = 3 b = 10 阅读全文
摘要:
二维数组查找 class Solution(): def chazhao2d(self, arr, m, n, p, q, tar) -> int: if n >= m or q >= p: mid_row = int(m + (n-m)/2) mid_col = int(p + (q-p)/2) 阅读全文
摘要:
冒泡排序算法 class Solution(): def maopao(self, arr: list) -> list: N = len(arr) for i in range(N-1,0,-1): for j in range(i): temp = 0 if arr[j] > arr[j+1]: 阅读全文
摘要:
快速排序算法 import random class Solution(): def quickSort(self, arr, head,tail): if head >= tail: return arr mid = head + random.randint(0,tail - head) piv 阅读全文