Problem
$n!$ means $n \times (n - 1) \times … \times 3 \times 2 \times 1$.
Find the sum of the digits in the number $100!$.
$n!$ means $n \times (n - 1) \times … \times 3 \times 2 \times 1$.
Find the sum of the digits in the number $100!$.
在Spring MVC中,将一个普通的java类标注上Controller注解之后,再将类中的方法使用RequestMapping注解标注,那么这个普通的java类就够处理Web请求,示例代码如下:
1 | /** |
spring通过java annotation就可以注释一个类为action ,在方法上添加上一个java annotation 就可以配置请求的路径了,那么这种机制是如何实现的呢,今天我们使用”自定义注解+Servlet”来简单模拟一下Spring MVC中的这种注解配置方式。
Given an integer array nums
, return the number of range sums that lie in [lower, upper]
inclusive.
Range sum S(i, j)
is defined as the sum of the elements in nums
between indices i
and j
(i
≤ j
), inclusive.
Note:
A naive algorithm of $O(n^2)$ is trivial. You MUST do better than that.
Example:
Given nums = [-2, 5, -1]
, lower = -2
, upper = 2
,
Return 3
.
The three ranges are : [0, 0], [2, 2], [0, 2]
and their respective sums are: -2, -1, 2
.
The count-and-say sequence is the sequence of integers with the first five terms as following:
1 | 1. 1 |
1
is read off as "one 1"
or 11
.11
is read off as "two 1s"
or 21
.21
is read off as "one 2
, then one 1"
or 1211
.
Given an integer $n$, generate the $n^th$ term of the count-and-say sequence.
Note: Each term of the sequence of integers will be represented as a string.
Example 1:1
2Input: 1
Output: "1"
Example 2:1
2Input: 4
Output: "1211"
Given an array where elements are sorted in ascending order, convert it to a height balanced BST.
For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the two subtrees of every node never differ by more than 1.
Example:1
2
3
4
5
6
7
8
9Given the sorted array: [-10,-3,0,5,9],
One possible answer is: [0,-3,9,-10,null,5], which represents the following height balanced BST:
0
/ \
-3 9
/ /
-10 5
Given a list of non-negative numbers and a target integer k, write a function to check if the array has a continuous subarray of size at least 2 that sums up to the multiple of k, that is, sums up to n*k where n is also an integer.
Example 1:1
2
3Input: [23, 2, 4, 6, 7], k=6
Output: True
Explanation: Because [2, 4] is a continuous subarray of size 2 and sums up to 6.
Example 2:1
2
3Input: [23, 2, 6, 4, 7], k=6
Output: True
Explanation: Because [23, 2, 6, 4, 7] is an continuous subarray of size 5 and sums up to 42.
Note: