Skip to content

Commit 9b714c1

Browse files
authored
Improved task 133
1 parent e882aa1 commit 9b714c1

File tree

1 file changed

+11
-6
lines changed
  • LeetCodeNet/G0101_0200/S0133_clone_graph

1 file changed

+11
-6
lines changed

LeetCodeNet/G0101_0200/S0133_clone_graph/Node.cs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
namespace LeetCodeNet.G0101_0200.S0133_clone_graph {
2+
23
public class Node {
34
public int val;
45
public IList<Node> neighbors;
@@ -20,27 +21,31 @@ public Node(int _val, List<Node> _neighbors) {
2021

2122
public override string ToString() {
2223
var result = new System.Text.StringBuilder();
23-
result.Append("[");
24+
result.Append('[');
2425
bool first = true;
2526
foreach (var node in neighbors) {
26-
if (!first) result.Append(",");
27+
if (!first) {
28+
result.Append(',');
29+
}
2730
if (node.neighbors == null || node.neighbors.Count == 0) {
2831
result.Append(node.val);
2932
} else {
3033
var inner = new System.Text.StringBuilder();
31-
inner.Append("[");
34+
inner.Append('[');
3235
bool innerFirst = true;
3336
foreach (var nodeItem in node.neighbors) {
34-
if (!innerFirst) inner.Append(",");
37+
if (!innerFirst) {
38+
inner.Append(',');
39+
}
3540
inner.Append(nodeItem.val);
3641
innerFirst = false;
3742
}
38-
inner.Append("]");
43+
inner.Append(']');
3944
result.Append(inner.ToString());
4045
}
4146
first = false;
4247
}
43-
result.Append("]");
48+
result.Append(']');
4449
return result.ToString();
4550
}
4651
}

0 commit comments

Comments
 (0)