摘要: // 非递归实现int Add (int num1, int num2){ int sum, carry; do{ sum = num1 ^ num2; // 做异或运算 carry = (num1 & num2) << 1; // 进位 ... 阅读全文
posted @ 2017-10-20 23:47 爱简单的Paul 阅读(166) 评论(0) 推荐(0) 编辑
摘要: DFS算法 思想:一直往深处走,直到找到解或者走不下去为止 DFS(dep,...) // dep代表目前DFS的深度 { if (找到解或者走不下去了){ return; } 枚举下种情况,DFS(dep + 1, ...) } DFS: 使用栈保存未被检测的节点,结点按照深度优先的次序被访问并依次压入栈中,并以相反的次序出栈进行新的检测 类似... 阅读全文
posted @ 2017-10-20 15:08 爱简单的Paul 阅读(1739) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree, determine if it is a valid binary search tree (BST). Assume a BST is defined as follows: The left subtree of a node contains only 阅读全文
posted @ 2017-10-20 11:33 爱简单的Paul 阅读(189) 评论(0) 推荐(0) 编辑
摘要: 输出是56 65.123 阅读全文
posted @ 2017-10-20 11:00 爱简单的Paul 阅读(4287) 评论(0) 推荐(0) 编辑
摘要: Find the kth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct element. For exam 阅读全文
posted @ 2017-10-20 10:29 爱简单的Paul 阅读(193) 评论(0) 推荐(0) 编辑
摘要: Given a singly linked list, return a random node's value from the linked list. Each node must have the same probability of being chosen. Follow up:Wha 阅读全文
posted @ 2017-10-20 09:58 爱简单的Paul 阅读(160) 评论(0) 推荐(0) 编辑