File tree Expand file tree Collapse file tree 3 files changed +114
-0
lines changed Expand file tree Collapse file tree 3 files changed +114
-0
lines changed Original file line number Diff line number Diff line change @@ -157,3 +157,5 @@ mod n0166_fraction_to_recurring_decimal;
157157mod n0167_two_sum_ii_input_array_is_sorted;
158158mod n0168_excel_sheet_column_title;
159159mod n0169_majority_element;
160+ mod n0171_excel_sheet_column_number;
161+ mod n0172_factorial_trailing_zeroes;
Original file line number Diff line number Diff line change 1+ /**
2+ * [171] Excel Sheet Column Number
3+ *
4+ * Given a column title as appear in an Excel sheet, return its corresponding column number.
5+ *
6+ * For example:
7+ *
8+ *
9+ * A -> 1
10+ * B -> 2
11+ * C -> 3
12+ * ...
13+ * Z -> 26
14+ * AA -> 27
15+ * AB -> 28
16+ * ...
17+ *
18+ *
19+ * Example 1:
20+ *
21+ *
22+ * Input: "A"
23+ * Output: 1
24+ *
25+ *
26+ * Example 2:
27+ *
28+ *
29+ * Input: "AB"
30+ * Output: 28
31+ *
32+ *
33+ * Example 3:
34+ *
35+ *
36+ * Input: "ZY"
37+ * Output: 701
38+ *
39+ */
40+ pub struct Solution { }
41+
42+ // submission codes start here
43+
44+ // TODO: boring
45+ impl Solution {
46+ pub fn title_to_number ( s : String ) -> i32 {
47+ 0
48+ }
49+ }
50+
51+ // submission codes end
52+
53+ #[ cfg( test) ]
54+ mod tests {
55+ use super :: * ;
56+
57+ #[ test]
58+ fn test_171 ( ) {
59+ }
60+ }
Original file line number Diff line number Diff line change 1+ /**
2+ * [172] Factorial Trailing Zeroes
3+ *
4+ * Given an integer n, return the number of trailing zeroes in n!.
5+ *
6+ * Example 1:
7+ *
8+ *
9+ * Input: 3
10+ * Output: 0
11+ * Explanation: 3! = 6, no trailing zero.
12+ *
13+ * Example 2:
14+ *
15+ *
16+ * Input: 5
17+ * Output: 1
18+ * Explanation: 5! = 120, one trailing zero.
19+ *
20+ * Note: Your solution should be in logarithmic time complexity.
21+ *
22+ */
23+ pub struct Solution { }
24+
25+ // submission codes start here
26+
27+ impl Solution {
28+ pub fn trailing_zeroes ( n : i32 ) -> i32 {
29+ let mut five_count = 0 ;
30+ let mut n = n;
31+ while n > 0 {
32+ n = n / 5 ;
33+ five_count += n;
34+ }
35+ five_count
36+ }
37+ }
38+
39+ // submission codes end
40+
41+ #[ cfg( test) ]
42+ mod tests {
43+ use super :: * ;
44+
45+ #[ test]
46+ fn test_172 ( ) {
47+ assert_eq ! ( Solution :: trailing_zeroes( 3 ) , 0 ) ;
48+ assert_eq ! ( Solution :: trailing_zeroes( 5 ) , 1 ) ;
49+ assert_eq ! ( Solution :: trailing_zeroes( 20 ) , 4 ) ;
50+ assert_eq ! ( Solution :: trailing_zeroes( 1808548329 ) , 452137076 ) ;
51+ }
52+ }
You can’t perform that action at this time.
0 commit comments