• leetcode 542
    Leetcode BFS Created Sun, 19 Apr 2020 19:40:53 +0800
  • 在二叉树中有各种各样的遍历算法,下面然我们来看看它们是怎么实现的。 二叉树的结构: type TreeNode struct { Val int Left *TreeNode Right *TreeNode } 递归 前序遍历 func preorderTraversal(root *TreeNode) []int { var l []int if root == nil { return l } l = append(l, root.Val) l = append(l,
    tree Leetcode Created Sun, 21 Apr 2019 19:35:37 +0800
  • 在《剑指Offer》7.2 章中,面试案例:树中两个节点的最低公共祖先,记录了如下面试流程: 面试官:让我们做一个编程题目吧。输入树的两个节点,求他们的最低公共祖先
    tree Leetcode Created Mon, 15 Apr 2019 07:45:14 +0800
  • 面试过程中,经常会遇到“快排”的这个题目,平时只是写出来了,但是一旦问到如何优化,就没有思路了。 今天看到《Algorithms Fourth Edition》中记录的“三向切
    排序 Created Sun, 23 Dec 2018 23:02:56 +0800
  • package main import "fmt" func main() { a := 2 b := 2 fmt.Println(add(a, b)) fmt.Println(sub(a, b)) fmt.Println(mul(a, b)) fmt.Println(div(a, b)) } func add(a, b int) int { if b == 0 { return a } tmp := 0 for b != 0 { tmp = (a & b) << 1 a = a ^ b b = tmp } return a } func addr(a, b int) int { if b == 0 { return a } tmp := (a
    mathematics Created Thu, 02 Aug 2018 00:26:55 +0800
  • Leetcode地址 Github地址 题干 Given a linked list, remove the n-th node from the end of list and return its head. 给定一个链表,删除链表的倒数第 n 个节点,并且返回链表的头结点。 Example: Given linked list: 1->2->3->4->5, and n = 2. After removing the
    Leetcode Linked list Created Wed, 01 Aug 2018 22:53:23 +0800
  • 题目 Given a string containing digits from 2-9 inclusive, return all possible letter combinations that the number could represent. 给定一个仅包含数字 2-9 的字符串,返回所有它能表示的字母组合。 A mapping of digit to letters (just like on the telephone buttons) is given below. Note that 1 does not map to any letters. 给出数字到字母
    Leetcode DFS BFS Created Thu, 26 Jul 2018 00:17:05 +0800