File tree 4 files changed +32
-38
lines changed
21.merge_two_sorted_lists
83.remove_duplicates_from_sorted_list
94.binary_tree_inorder_traversal
4 files changed +32
-38
lines changed Original file line number Diff line number Diff line change 7
7
8
8
import '../../structure/list_node.dart' ;
9
9
10
- /**
11
- * Definition for singly-linked list.
12
- * class ListNode {
13
- * int val;
14
- * ListNode? next;
15
- * ListNode([this.val = 0, this.next] );
16
- * }
17
- */
10
+ /// Definition for singly-linked list.
11
+ /// class ListNode {
12
+ /// int val;
13
+ /// ListNode? next;
14
+ /// ListNode([this.val = 0, this.next] );
15
+ /// }
18
16
class Solution {
19
17
ListNode ? mergeTwoLists (ListNode ? list1, ListNode ? list2) {
20
18
ListNode dummy = ListNode (0 );
Original file line number Diff line number Diff line change 9
9
10
10
import 'package:leetcode/src/structure/list_node.dart' ;
11
11
12
- /**
13
- * Definition for singly-linked list.
14
- * class ListNode {
15
- * int val;
16
- * ListNode? next;
17
- * ListNode([this.val = 0, this.next] );
18
- * }
19
- */
12
+ /// Definition for singly-linked list.
13
+ /// class ListNode {
14
+ /// int val;
15
+ /// ListNode? next;
16
+ /// ListNode([this.val = 0, this.next] );
17
+ /// }
20
18
class Solution {
21
19
ListNode ? deleteDuplicates (ListNode ? head) {
22
20
if (head == null ) return null ;
Original file line number Diff line number Diff line change 3
3
4
4
import 'package:leetcode/src/structure/tree_node.dart' ;
5
5
6
- /**
7
- * Definition for a binary tree node.
8
- * class TreeNode {
9
- * int val;
10
- * TreeNode? left;
11
- * TreeNode? right;
12
- * TreeNode([this.val = 0, this.left, this.right] );
13
- * }
14
- */
6
+ /// Definition for a binary tree node.
7
+ /// class TreeNode {
8
+ /// int val;
9
+ /// TreeNode? left;
10
+ /// TreeNode? right;
11
+ /// TreeNode([this.val = 0, this.left, this.right] );
12
+ /// }
15
13
class Solution {
16
14
List <int > inorderTraversal (TreeNode ? root) {
17
15
List <int > res = [];
Original file line number Diff line number Diff line change @@ -38,19 +38,19 @@ void main(List<String> args) {
38
38
/// The time complexity of this variant is `O(n * k * log(k))` , where `n` is the length of
39
39
/// the input list `strs` and `k` is the maximum length of a string in `strs` .
40
40
41
- List <List <String >> _groupAnagrams (List <String > strs) {
42
- Map <String , List <String >> anagramGroups = {};
43
-
44
- for (String str in strs) {
45
- String sortedStr = String .fromCharCodes (str.runes.toList ()..sort ());
46
- if (! anagramGroups.containsKey (sortedStr)) {
47
- anagramGroups[sortedStr] = [];
48
- }
49
- anagramGroups[sortedStr]? .add (str);
50
- }
51
-
52
- return anagramGroups.values.toList ();
53
- }
41
+ // List<List<String>> _groupAnagrams(List<String> strs) {
42
+ // Map<String, List<String>> anagramGroups = {};
43
+
44
+ // for (String str in strs) {
45
+ // String sortedStr = String.fromCharCodes(str.runes.toList()..sort());
46
+ // if (!anagramGroups.containsKey(sortedStr)) {
47
+ // anagramGroups[sortedStr] = [];
48
+ // }
49
+ // anagramGroups[sortedStr]?.add(str);
50
+ // }
51
+
52
+ // return anagramGroups.values.toList();
53
+ // }
54
54
55
55
/// NB: The sorting variant is slower than counting the frequency of each character.
56
56
/// However, the second algorithm may be faster than the first algorithm for inputs
You can’t perform that action at this time.
0 commit comments