摘要:
Given an integern, return the number of trailing zeroes inn!.问题描述:给出一个正整数n,计算n!结构后面有几个0.要求:在多项式时间中完成算法。常规思路:计算n!,然后统计一下后面有几个0,但是这种算法一想就知道肯定会超出时间限制。巧妙思... 阅读全文
摘要:
Write an algorithm to determine if a number is "happy".A happy number is a number defined by the following process: Starting with any positive integer... 阅读全文
摘要:
Remove all elements from a linked list of integers that have value val. ExampleGiven: 1 --> 2 --> 6 --> 3 --> 4 --> 5 --> 6, val = 6Return: 1 --> 2 -- 阅读全文
摘要:
Count the number of prime numbers less than a non-negative number,n.1.常规思路(计算复杂度为O(n*sqrt(n))),提交后超时。public static boolean isPrime(int m){ bool... 阅读全文