File tree Expand file tree Collapse file tree 2 files changed +26
-2
lines changed
insert-into-a-binary-search-tree Expand file tree Collapse file tree 2 files changed +26
-2
lines changed Original file line number Diff line number Diff line change
1
+ // +build ignore
2
+
3
+ #pragma once
4
+ #include < queue>
5
+ #include < string>
6
+
7
+ using namespace std ;
8
+ #include " TreeNode.hpp"
9
+ #include " bfsTravelsal.hpp"
10
+
11
+ #include < iostream>
12
+ #include < iterator>
13
+ #include < regex>
14
+ #include < sstream>
15
+ std::string LeetCodeTreeNodeToString (TreeNode *root) {
16
+ stringstream sstream;
17
+ auto result = bfsTravelsal (root);
18
+ std::regex vowel_re (" (,null){1,}\\ ]$" );
19
+
20
+ std::regex_replace (std::ostreambuf_iterator<char >(sstream), result.begin (),
21
+ result.end (), vowel_re, " ]" );
22
+ return sstream.str ();
23
+ }
Original file line number Diff line number Diff line change 19
19
using namespace std ;
20
20
#include " EqualTreeNode.hpp"
21
21
#include " HashTreeNode.hpp"
22
- #include " bfsTravelsal.hpp"
22
+ // #include "bfsTravelsal.hpp"
23
23
#include " debugTreeNode.hpp"
24
24
#include " printTreeNode.hpp"
25
25
#include " treeparse.hpp"
26
+ #include " LeetCodeTreeNodeToString.hpp"
26
27
27
28
void println (string s) { cout << s << endl; }
28
29
@@ -103,7 +104,7 @@ class StringTest : public CppUnit::TestFixture {
103
104
CPPUNIT_ASSERT_EQUAL (0 , status);
104
105
105
106
printTreeNode (root);
106
- std::string result = bfsTravelsal (root);
107
+ std::string result = LeetCodeTreeNodeToString (root);
107
108
108
109
println (result);
109
110
cleanTreeNode (root);
You can’t perform that action at this time.
0 commit comments