File tree 4 files changed +50
-1
lines changed
4 files changed +50
-1
lines changed Original file line number Diff line number Diff line change @@ -38,6 +38,7 @@ Profile on LeetCode: [fartem](https://leetcode.com/fartem/).
38
38
| 111. Minimum Depth of Binary Tree | [Link](https://leetcode.com/problems/minimum-depth-of-binary-tree/) | [Link](./lib/easy/111_minimum_depth_of_binary_tree.dart) |
39
39
| 112. Path Sum | [Link](https://leetcode.com/problems/path-sum/) | [Link](./lib/easy/112_path_sum.dart) |
40
40
| 118. Pascal's Triangle | [Link](https://leetcode.com/problems/pascals-triangle/) | [Link](./lib/easy/118_pascals_triangle.dart) |
41
+ | 263. Ugly Number | [Link](https://lettcode.com/problems/ugly-number/) | [Link](./lib/easy/263_ugly_number.dart) |
41
42
| 500. Keyboard Row | [Link](https://leetcode.com/problems/keyboard-row/) | [Link](./lib/easy/500_keyboard_row.dart) |
42
43
| 3280. Convert Date to Binary | [Link](https://leetcode.com/problems/convert-date-to-binary/) | [Link](./lib/easy/3280_convert_date_to_binary.dart) |
43
44
| 3516. Find Closest Person | [Link](https://leetcode.com/problems/find-closest-person/) | [Link](./lib/easy/3516_find_closest_person.dart) |
Original file line number Diff line number Diff line change
1
+ class Solution {
2
+ bool isUgly(int n) {
3
+ if (n <= 0) {
4
+ return false;
5
+ }
6
+
7
+ for (final p in [2, 3, 5]) {
8
+ while (n % p == 0) {
9
+ n ~/= p;
10
+ }
11
+ }
12
+
13
+ return n == 1;
14
+ }
15
+ }
Original file line number Diff line number Diff line change 1
1
name: leetcode_dart
2
2
description: Some solved problems from https://leetcode.com on Dart
3
- version: 1.0.4
3
+ version: 1.0.5
4
4
homepage: https://github.com/fartem/leetcode-dart
5
5
6
6
environment:
Original file line number Diff line number Diff line change
1
+ import 'package:leetcode_dart/easy/263_ugly_number.dart';
2
+ import 'package:test/test.dart';
3
+
4
+ void main() {
5
+ group(
6
+ 'Example tests',
7
+ () {
8
+ final solution = Solution();
9
+
10
+ test(
11
+ '6',
12
+ () => expect(
13
+ true,
14
+ solution.isUgly(6),
15
+ ),
16
+ );
17
+ test(
18
+ '1',
19
+ () => expect(
20
+ true,
21
+ solution.isUgly(6),
22
+ ),
23
+ );
24
+ test(
25
+ '14',
26
+ () => expect(
27
+ true,
28
+ solution.isUgly(6),
29
+ ),
30
+ );
31
+ },
32
+ );
33
+ }
You can’t perform that action at this time.
0 commit comments