Skip to content

Commit 6a0855c

Browse files
authored
Merge pull request #31 from fartem/refactoring-1
2025-05-01 v. 1.0.2: refactored project
2 parents c7a882c + a523c98 commit 6a0855c

File tree

68 files changed

+605
-338
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+605
-338
lines changed

.github/workflows/dart.yml

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,41 @@ on:
66
pull_request:
77
branches: [ master ]
88

9+
env:
10+
DART_VERSION: "3.7.2"
11+
912
jobs:
10-
build:
13+
analyzer:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v2
17+
- uses: dart-lang/setup-dart@v1.0
18+
with:
19+
sdk: ${{ env.DART_VERSION }}
20+
- name: Install dependencies
21+
run: dart pub get
22+
- name: Run tests
23+
run: dart analyze
24+
25+
formatter:
26+
runs-on: ubuntu-latest
27+
steps:
28+
- uses: actions/checkout@v2
29+
- uses: dart-lang/setup-dart@v1.0
30+
with:
31+
sdk: ${{ env.DART_VERSION }}
32+
- name: Install dependencies
33+
run: dart pub get
34+
- name: Run tests
35+
run: dart format -l 120 --set-exit-if-changed ./
36+
37+
tests:
1138
runs-on: ubuntu-latest
1239
steps:
1340
- uses: actions/checkout@v2
1441
- uses: dart-lang/setup-dart@v1.0
1542
with:
16-
sdk: 3.7.2
43+
sdk: ${{ env.DART_VERSION }}
1744
- name: Install dependencies
1845
run: dart pub get
1946
- name: Run tests

README.md

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -12,30 +12,30 @@ Profile on LeetCode: [fartem](https://leetcode.com/fartem/).
1212

1313
### Easy
1414

15-
| Name | Link to LeetCode | Link to solution |
16-
| ----------------------------------------------- | --------------------------------------------------------------------------------- | ------------------------------------------------------------------ |
17-
| 1. Two Sum | [Link](https://leetcode.com/problems/two-sum/) | [Link](./lib/easy/two_sum.dart) |
18-
| 9. Palindrome Number | [Link](https://leetcode.com/problems/palindrome-number/) | [Link](./lib/easy/palindrome_number.dart) |
19-
| 13. Roman to Integer | [Link](https://leetcode.com/problems/roman-to-integer/) | [Link](./lib/easy/roman_to_integer.dart) |
20-
| 14. Longest Common Prefix | [Link](https://leetcode.com/problems/longest-common-prefix/) | [Link](./lib/easy/longest_common_prefix.dart) |
21-
| 20. Valid Parentheses | [Link](https://leetcode.com/problems/valid-parentheses/) | [Link](./lib/easy/valid_parentheses.dart) |
22-
| 21. Merge Two Sorted Lists | [Link](https://leetcode.com/problems/merge-two-sorted-lists/) | [Link](./lib/easy/merge_two_sorted_lists.dart) |
23-
| 27. Remove Element | [Link](https://leetcode.com/problems/remove-element/) | [Link](./lib/easy/remove_element.dart) |
24-
| 35. Search Insert Position | [Link](https://leetcode.com/problems/search-insert-position/) | [Link](./lib/easy/search_insert_position.dart) |
25-
| 58. Length of Last Word | [Link](https://leetcode.com/problems/length-of-last-word/) | [Link](./lib/easy/length_of_last_word.dart) |
26-
| 66. Plus One | [Link](https://leetcode.com/problems/plus-one/) | [Link](./lib/easy/plus_one.dart) |
27-
| 67. Add Binary | [Link](https://leetcode.com/problems/add-binary/) | [Link](./lib/easy/add_binary.dart) |
28-
| 69. Sqrt(x) | [Link](https://leetcode.com/problems/sqrtx/) | [Link](./lib/easy/sqrt_x.dart) |
29-
| 70. Climbing Stairs | [Link](https://leetcode.com/problems/climbing-stairs/) | [Link](./lib/easy/climbing_stairs.dart) |
30-
| 83. Remove Duplicates from Sorted List | [Link](https://leetcode.com/problems/remove-duplicates-from-sorted-list/) | [Link](./lib/easy/remove_duplicates_from_sorted_list.dart) |
31-
| 88. Merge Sorted Array | [Link](https://leetcode.com/problems/merge-sorted-array/) | [Link](./lib/easy/merge_sorted_array.dart) |
32-
| 94. Binary Tree Inorder Traversal | [Link](https://leetcode.com/problems/binary-tree-inorder-traversal/) | [Link](./lib/easy/binary_tree_inorder_traversal.dart) |
33-
| 100. Same Tree | [Link](https://leetcode.com/problems/same-tree/) | [Link](./lib/easy/same_tree.dart) |
34-
| 101. Symmetric Tree | [Link](https://leetcode.com/problems/symmetric-tree/) | [Link](./lib/easy/symmetric_tree.dart) |
35-
| 104. Maximum Depth of Binary Tree | [Link](https://leetcode.com/problems/maximum-depth-of-binary-tree/) | [Link](./lib/easy/maximum_depth_of_binary_tree.dart) |
36-
| 108. Convert Sorted Array to Binary Search Tree | [Link](https://leetcode.com/problems/convert-sorted-array-to-binary-search-tree/) | [Link](./lib/easy/convert_sorted_array_to_binary_search_tree.dart) |
37-
| 110. Balanced Binary Tree | [Link](https://leetcode.com/problems/balanced-binary-tree/) | [Link](./lib/easy/balanced_binary_tree.dart) |
38-
| 111. Minimum Depth of Binary Tree | [Link](https://leetcode.com/problems/minimum-depth-of-binary-tree/) | [Link](./lib/easy/minimum_depth_of_binary_tree.dart) |
39-
| 112. Path Sum | [Link](https://leetcode.com/problems/path-sum/) | [Link](./lib/easy/path_sum.dart) |
40-
| 118. Pascal's Triangle | [Link](https://leetcode.com/problems/pascals-triangle/) | [Link](./lib/easy/pascals_triangle.dart) |
41-
| 3516. Find Closest Person | [Link](https://leetcode.com/problems/find-closest-person/) | [Link](./lib/easy/find_closest_person.dart) |
15+
| Name | Link to LeetCode | Link to solution |
16+
| ----------------------------------------------- | --------------------------------------------------------------------------------- | ---------------------------------------------------------------------- |
17+
| 1. Two Sum | [Link](https://leetcode.com/problems/two-sum/) | [Link](./lib/easy/1_two_sum.dart) |
18+
| 9. Palindrome Number | [Link](https://leetcode.com/problems/palindrome-number/) | [Link](./lib/easy/9_palindrome_number.dart) |
19+
| 13. Roman to Integer | [Link](https://leetcode.com/problems/roman-to-integer/) | [Link](./lib/easy/13_roman_to_integer.dart) |
20+
| 14. Longest Common Prefix | [Link](https://leetcode.com/problems/longest-common-prefix/) | [Link](./lib/easy/14_longest_common_prefix.dart) |
21+
| 20. Valid Parentheses | [Link](https://leetcode.com/problems/valid-parentheses/) | [Link](./lib/easy/20_valid_parentheses.dart) |
22+
| 21. Merge Two Sorted Lists | [Link](https://leetcode.com/problems/merge-two-sorted-lists/) | [Link](./lib/easy/21_merge_two_sorted_lists.dart) |
23+
| 27. Remove Element | [Link](https://leetcode.com/problems/remove-element/) | [Link](./lib/easy/27_remove_element.dart) |
24+
| 35. Search Insert Position | [Link](https://leetcode.com/problems/search-insert-position/) | [Link](./lib/easy/35_search_insert_position.dart) |
25+
| 58. Length of Last Word | [Link](https://leetcode.com/problems/length-of-last-word/) | [Link](./lib/easy/58_length_of_last_word.dart) |
26+
| 66. Plus One | [Link](https://leetcode.com/problems/plus-one/) | [Link](./lib/easy/66_plus_one.dart) |
27+
| 67. Add Binary | [Link](https://leetcode.com/problems/add-binary/) | [Link](./lib/easy/67_add_binary.dart) |
28+
| 69. Sqrt(x) | [Link](https://leetcode.com/problems/sqrtx/) | [Link](./lib/easy/69_sqrt_x.dart) |
29+
| 70. Climbing Stairs | [Link](https://leetcode.com/problems/climbing-stairs/) | [Link](./lib/easy/70_climbing_stairs.dart) |
30+
| 83. Remove Duplicates from Sorted List | [Link](https://leetcode.com/problems/remove-duplicates-from-sorted-list/) | [Link](./lib/easy/83_remove_duplicates_from_sorted_list.dart) |
31+
| 88. Merge Sorted Array | [Link](https://leetcode.com/problems/merge-sorted-array/) | [Link](./lib/easy/88_merge_sorted_array.dart) |
32+
| 94. Binary Tree Inorder Traversal | [Link](https://leetcode.com/problems/binary-tree-inorder-traversal/) | [Link](./lib/easy/94_binary_tree_inorder_traversal.dart) |
33+
| 100. Same Tree | [Link](https://leetcode.com/problems/same-tree/) | [Link](./lib/easy/100_same_tree.dart) |
34+
| 101. Symmetric Tree | [Link](https://leetcode.com/problems/symmetric-tree/) | [Link](./lib/easy/101_symmetric_tree.dart) |
35+
| 104. Maximum Depth of Binary Tree | [Link](https://leetcode.com/problems/maximum-depth-of-binary-tree/) | [Link](./lib/easy/104_maximum_depth_of_binary_tree.dart) |
36+
| 108. Convert Sorted Array to Binary Search Tree | [Link](https://leetcode.com/problems/convert-sorted-array-to-binary-search-tree/) | [Link](./lib/easy/108_convert_sorted_array_to_binary_search_tree.dart) |
37+
| 110. Balanced Binary Tree | [Link](https://leetcode.com/problems/balanced-binary-tree/) | [Link](./lib/easy/110_balanced_binary_tree.dart) |
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+
| 112. Path Sum | [Link](https://leetcode.com/problems/path-sum/) | [Link](./lib/easy/112_path_sum.dart) |
40+
| 118. Pascal's Triangle | [Link](https://leetcode.com/problems/pascals-triangle/) | [Link](./lib/easy/118_pascals_triangle.dart) |
41+
| 3516. Find Closest Person | [Link](https://leetcode.com/problems/find-closest-person/) | [Link](./lib/easy/3516_find_closest_person.dart) |

analysis_options.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
11
include: package:lints/core.yaml
2+
3+
linter:
4+
rules:
5+
file_names: false

lib/common/tree_node.dart

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,5 @@ class TreeNode {
33
TreeNode? left;
44
TreeNode? right;
55

6-
TreeNode([
7-
this.val = 0,
8-
this.left,
9-
this.right,
10-
]);
6+
TreeNode([this.val = 0, this.left, this.right]);
117
}
File renamed without changes.
File renamed without changes.

lib/easy/balanced_binary_tree.dart renamed to lib/easy/110_balanced_binary_tree.dart

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,14 @@ class Solution {
88
if (root != null) {
99
var l = _maxHeight(root.left);
1010
var r = _maxHeight(root.right);
11-
return (l - r).abs() < 2 &&
12-
isBalanced(root.left) &&
13-
isBalanced(root.right);
11+
return (l - r).abs() < 2 && isBalanced(root.left) && isBalanced(root.right);
1412
}
1513
return true;
1614
}
1715

1816
int _maxHeight(TreeNode? node) {
1917
if (node != null) {
20-
return 1 +
21-
max(
22-
_maxHeight(node.left),
23-
_maxHeight(node.right),
24-
);
18+
return 1 + max(_maxHeight(node.left), _maxHeight(node.right));
2519
}
2620
return 0;
2721
}

lib/easy/minimum_depth_of_binary_tree.dart renamed to lib/easy/111_minimum_depth_of_binary_tree.dart

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,7 @@ class Solution {
1313
} else if (root.right == null) {
1414
return minDepth(root.left) + 1;
1515
}
16-
return min(
17-
minDepth(root.left) + 1,
18-
minDepth(root.right) + 1,
19-
);
16+
return min(minDepth(root.left) + 1, minDepth(root.right) + 1);
2017
}
2118
return 0;
2219
}

0 commit comments

Comments
 (0)