File tree Expand file tree Collapse file tree 4 files changed +50
-1
lines changed Expand file tree Collapse file tree 4 files changed +50
-1
lines changed Original file line number Diff line number Diff line change @@ -41,5 +41,6 @@ Profile on LeetCode: [fartem](https://leetcode.com/fartem/).
4141| 263. Ugly Number | [ Link] ( https://lettcode.com/problems/ugly-number/ ) | [ Link] ( ./lib/easy/263_ugly_number.dart ) |
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 ) |
44+ | 3340. Check Balanced String | [ Link] ( https://leetcode.com/problems/check-balanced-string/ ) | [ Link] ( ./lib/easy/3340_check_balanced_string.dart ) |
4445| 3516. Find Closest Person | [ Link] ( https://leetcode.com/problems/find-closest-person/ ) | [ Link] ( ./lib/easy/3516_find_closest_person.dart ) |
4546| 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 number Diff line number Diff line change 1+ class Solution {
2+ bool isBalanced (String num ) {
3+ var even = 0 ;
4+ var odd = 0 ;
5+
6+ for (var i = 0 ; i < num .length; i += 1 ) {
7+ final curr = int .parse (num [i]);
8+
9+ if (i.isEven) {
10+ even += curr;
11+ } else {
12+ odd += curr;
13+ }
14+ }
15+
16+ return even == odd;
17+ }
18+ }
Original file line number Diff line number Diff line change 11name : leetcode_dart
22description : Some solved problems from https://leetcode.com on Dart
3- version : 1.0.6
3+ version : 1.0.7
44homepage : https://github.com/fartem/leetcode-dart
55
66environment :
Original file line number Diff line number Diff line change 1+ import 'package:leetcode_dart/easy/3340_check_balanced_string.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+ 'false' ,
12+ () => expect (
13+ false ,
14+ solution.isBalanced (
15+ '1234' ,
16+ ),
17+ ),
18+ );
19+ test (
20+ 'true' ,
21+ () => expect (
22+ true ,
23+ solution.isBalanced (
24+ '24123' ,
25+ ),
26+ ),
27+ );
28+ },
29+ );
30+ }
You can’t perform that action at this time.
0 commit comments