摘要:
问题描述Given an integer n, count the total number of digit 1 appearing in all non-negative integers less than or equal to n.For example:Given n = 13,Retu... 阅读全文
摘要:
问题描述Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST.According to thedefinition of LCA on Wikiped... 阅读全文
摘要:
问题描述输入1个整数,求其二进制表示中有多少个“1”。解决思路1. 不断右移,碰到1与0与,计数;(对于负数不可,会死循环);2. 与(n-1)与,相当于清除最右端的“1”,计数。程序思路2:public class NumOfOne { public int getNumOfOne(int num... 阅读全文