![](https://img-blog.csdnimg.cn/20201014180756916.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
C++
「已注销」
这个作者很懒,什么都没留下…
展开
-
整数除法的取整方式
在二分查找中,我们常用到以下表现int low=x;int high=y;int mid=(low+high)/2;由于C++在处理整数除法的时候,是向零取整的,即:int a=(1+2)/2;//a=1int a=(-1-2)/2,//a=-1故low由此在有关 的二分查找实现中(类似:Find Peak Element—LeetCode第三种方式点击打开链接),原创 2015-04-11 20:28:01 · 2478 阅读 · 1 评论 -
Lowest Common Ancestor of a Binary Search Tree-leetcode
Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST.According to the definition of LCA on Wikipedia: “The lowest common ancestor is defined betw原创 2015-07-19 19:52:37 · 297 阅读 · 0 评论 -
258 Add Digits - LeetCode
Given a non-negative integer num, repeatedly add all its digits until the result has only one digit.For example:Given num = 38, the process is like: 3 + 8 = 11, 1 + 1 = 2. Since 2 has on原创 2015-08-22 14:04:24 · 298 阅读 · 0 评论