Skip to content

Commit 3111dc2

Browse files
authored
Merge pull request #35 from fartem/3536-Maximum-Product-of-Two-Digits
2025-05-05 v. 1.0.6: added "3536. Maximum Product of Two Digits"
2 parents 8beee47 + dfc2cb1 commit 3111dc2

File tree

4 files changed

+50
-1
lines changed

4 files changed

+50
-1
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,4 @@ Profile on LeetCode: [fartem](https://leetcode.com/fartem/).
4242
| 500. Keyboard Row | [Link](https://leetcode.com/problems/keyboard-row/) | [Link](./lib/easy/500_keyboard_row.dart) |
4343
| 3280. Convert Date to Binary | [Link](https://leetcode.com/problems/convert-date-to-binary/) | [Link](./lib/easy/3280_convert_date_to_binary.dart) |
4444
| 3516. Find Closest Person | [Link](https://leetcode.com/problems/find-closest-person/) | [Link](./lib/easy/3516_find_closest_person.dart) |
45+
| 3536. Maximum Product of Two Digits | [Link](https://leetcode.com/problems/maximum-product-of-two-digits/) | [Link](./lib/easy/3536_maximum_product_of_two_digits.dart) |
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
class Solution {
2+
int maxProduct(int n) {
3+
final digits = [];
4+
5+
while (n != 0) {
6+
digits.add(n % 10);
7+
8+
n = n ~/ 10;
9+
}
10+
11+
digits.sort();
12+
13+
return digits[digits.length - 1] * digits[digits.length - 2];
14+
}
15+
}

pubspec.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: leetcode_dart
22
description: Some solved problems from https://leetcode.com on Dart
3-
version: 1.0.5
3+
version: 1.0.6
44
homepage: https://github.com/fartem/leetcode-dart
55

66
environment:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import 'package:leetcode_dart/easy/3536_maximum_product_of_two_digits.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+
'3',
12+
() => expect(
13+
3,
14+
solution.maxProduct(31),
15+
),
16+
);
17+
test(
18+
'4',
19+
() => expect(
20+
4,
21+
solution.maxProduct(22),
22+
),
23+
);
24+
test(
25+
'8',
26+
() => expect(
27+
8,
28+
solution.maxProduct(124),
29+
),
30+
);
31+
},
32+
);
33+
}

0 commit comments

Comments
 (0)