File tree Expand file tree Collapse 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 Expand file tree Collapse file tree 4 files changed +32
-38
lines changed Original file line number Diff line number Diff line change 77
88import '../../structure/list_node.dart' ;
99
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+ /// }
1816class Solution {
1917 ListNode ? mergeTwoLists (ListNode ? list1, ListNode ? list2) {
2018 ListNode dummy = ListNode (0 );
Original file line number Diff line number Diff line change 99
1010import 'package:leetcode/src/structure/list_node.dart' ;
1111
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+ /// }
2018class Solution {
2119 ListNode ? deleteDuplicates (ListNode ? head) {
2220 if (head == null ) return null ;
Original file line number Diff line number Diff line change 33
44import 'package:leetcode/src/structure/tree_node.dart' ;
55
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+ /// }
1513class Solution {
1614 List <int > inorderTraversal (TreeNode ? root) {
1715 List <int > res = [];
Original file line number Diff line number Diff line change @@ -38,19 +38,19 @@ void main(List<String> args) {
3838/// The time complexity of this variant is `O(n * k * log(k))` , where `n` is the length of
3939/// the input list `strs` and `k` is the maximum length of a string in `strs` .
4040
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+ // }
5454
5555/// NB: The sorting variant is slower than counting the frequency of each character.
5656/// 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