@@ -41,7 +41,9 @@ public class _385 {
4141 //if it's ']', we'll just pop one nested integer from the working stack and assign it to the result
4242
4343 public NestedInteger deserialize (String s ) {
44- if (s == null || s .isEmpty () || s .length () == 0 ) return new NestedInteger ();
44+ if (s == null || s .isEmpty () || s .length () == 0 ) {
45+ return new NestedInteger ();
46+ }
4547 Stack <NestedInteger > workStack = new Stack <NestedInteger >();
4648 NestedInteger result = null ;
4749 StringBuilder sb = new StringBuilder ();
@@ -85,10 +87,11 @@ public NestedInteger deserialize(String s) {
8587 }
8688 int num = Integer .parseInt (sb .toString ());
8789 NestedInteger ni = null ;
88- if (!workStack .isEmpty ())
90+ if (!workStack .isEmpty ()) {
8991 ni = workStack .pop ();
90- else
92+ } else {
9193 ni = new NestedInteger ();
94+ }
9295 // case 1: if this one contains one integer
9396 if (ni .isInteger ()) {
9497 // we'll add it to this ni
@@ -99,12 +102,16 @@ public NestedInteger deserialize(String s) {
99102 ni .add (new NestedInteger (num ));
100103 } else {
101104 // case 3: if this is an empty nested integer
102- if (i > 0 ) ni .add (new NestedInteger (num ));
103- else ni .setInteger (num );
105+ if (i > 0 ) {
106+ ni .add (new NestedInteger (num ));
107+ } else {
108+ ni .setInteger (num );
109+ }
104110 }
105111 workStack .push (ni );
106- if (i == s .length ())
112+ if (i == s .length ()) {
107113 return ni ;// this is for test cases like this: "324", there's no '[' or ']'
114+ }
108115 }
109116 }
110117 }
0 commit comments