数据结构
hello
ItisNagatoYuki
这个作者很懒,什么都没留下…
展开
-
算法 - php - 二叉树遍历
<?php class TreeNode { public function __construct($val) { $this->val = $val; $this->left = null; $this->right = null; } } #前序遍历 根 左 右 function preOrder($root) { echo $root->val . PHP_EOL; if ($r原创 2020-05-12 12:15:03 · 167 阅读 · 1 评论 -
算法 - python - 判断链表是否有环
class ListNode: def __init__(self, val): self.val = val self.next = None # 借助辅助空间 # class Solution: # def hasCycle(self, head: ListNode) -> bool: # a = set() # while head: # if head in a: #原创 2020-05-10 22:41:57 · 192 阅读 · 0 评论 -
算法 - pyhton - 二分查找
def bs(a, num): low = 0 high = len(a) - 1 mid = int(high / 2) while low<high: #当low == high 的时候查不到值那就不会存在了 if num < a[mid]: high = mid elif num &...原创 2020-05-03 01:31:50 · 210 阅读 · 0 评论