![](https://img-blog.csdnimg.cn/20201014180756923.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
算法
文章平均质量分 55
liuliu_fish
这个作者很懒,什么都没留下…
展开
-
Multiples of 3 and 5
If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. Find the sum of all the multiples of 3 or 5 below 1000.我们列举10以下的自然数且是3原创 2017-08-09 14:52:08 · 399 阅读 · 0 评论 -
二叉树的三种遍历(先序,中序,后序)
二叉树的遍历 1、递归形式的遍历 1.1先序遍历 先访问父亲节点,在访问左叶子节点,在访问右叶子节点,代码如下: void preOrder(TreeNode root){ if(root!=null){ vistit(root); ...原创 2018-04-11 21:50:08 · 1244 阅读 · 0 评论 -
二叉树的层次遍历
二叉树的层次遍历使用队列的特性,先进先出。void levelOrder(TreeNode root){ Queue(); queue.inQueue(root); while(queue.isNotEmpty()){ TreeNode node=queue.outQueue(); visit(node); if(node->lchild!=null){ ...原创 2018-04-11 22:00:52 · 116 阅读 · 0 评论 -
Binary Search Tree Iterator------leetCode
Implement an iterator over a binary search tree (BST). Your iterator will be initialized with the root node of a BST.Calling next() will return the next smallest number in the BST.Note: next() and...原创 2018-08-01 19:46:15 · 87 阅读 · 0 评论 -
434. Number of Segments in a String--leetcode
Count the number of segments in a string, where a segment is defined to be a contiguous sequence of non-space characters.Please note that the string does not contain any non-printable characters.E...原创 2018-08-22 10:59:16 · 154 阅读 · 0 评论 -
Write a function that takes an unsigned integer and returns the number of '1' bits it has -leetCode
求解一个无符号整数中1的个数思路:1:采用取模方法求解2:移位运算求解3:java内置函数 bitCount()代码实现:(1)取余int bitCount(int n){ int k; if(n==0)//如果n=0返回0 return 0; int count =0; while(n>=1){ k=...原创 2018-08-21 15:55:46 · 915 阅读 · 0 评论 -
599. Minimum Index Sum of Two Lists --- -leetCode
Suppose Andy and Doris want to choose a restaurant for dinner, and they both have a list of favorite restaurants represented by strings.You need to help them find out their common interest with the ...原创 2018-08-21 17:50:54 · 112 阅读 · 0 评论 -
爬楼梯问题
有一楼梯共n级,刚开始时你在第一级,若每次只能跨上一级或者二级,要走上n级,共有多少走法?输入:台阶数量 n输出:多少种走法 m问题分析: 此题就是动态规划问题,设走第i层楼梯需要countWay[i]种方法,走第i-1层楼梯需要countWay[i-1]种方法。则走第i+1层楼梯的方法种数为countWay[i-1]+countWay[i]种方法。例如:n=1 1n=2 ...原创 2018-09-10 16:39:50 · 858 阅读 · 0 评论