# The TransCompilator — Solved Programs · Chunk 03

Programs #0101–#0151 · 50 of 1,000 solved programs.

[Static catalog](https://ponvasanthpon.github.io/TransCompilator/problems/) · [llms.txt](https://ponvasanthpon.github.io/TransCompilator/llms.txt) · [Sitemap](https://ponvasanthpon.github.io/TransCompilator/sitemap.xml) · [Playground](https://ponvasanthpon.github.io/TransCompilator/)

Each entry contains the original natural-English `.eng` source and the
expected stdout. No LeetCode problem statement is copied.

---

## #0101 · Symmetric Tree

**Easy · Depth-First Search** · [Open in Playground](https://ponvasanthpon.github.io/TransCompilator/#problem=0101) · [Static page](https://ponvasanthpon.github.io/TransCompilator/problems/0101.html)

```text
Keep a shared values holding 1, 2, 2, 3, 4, 4, and 3. Keep a shared lefts holding 1, 3, 5, -1, -1, -1, and -1. Keep a shared rights holding 2, 4, 6, -1, -1, -1, and -1. Keep a shared same of 1.
To mirror from first (a whole number) with second (a whole number). If same is 0, return. If first is -1 and second is -1, return. If first is -1, set same to 0, return. If second is -1, set same to 0, return. If item first of values is not item second of values, set same to 0, return. Mirror from item first of lefts with item second of rights. Mirror from item first of rights with item second of lefts.

Mirror from 1 with 2. If same is 1, show true, otherwise show false.
```

**Expected stdout**

```text
true
```

## #0102 · Binary Tree Level Order Traversal

**Medium · Breadth-First Search** · [Open in Playground](https://ponvasanthpon.github.io/TransCompilator/#problem=0102) · [Static page](https://ponvasanthpon.github.io/TransCompilator/problems/0102.html)

```text
Keep a shared values holding 3, 9, 20, 15, and 7. Keep a shared lefts holding 1, -1, 3, -1, and -1. Keep a shared rights holding 2, -1, 4, -1, and -1.

The queue is an empty list of whole numbers. Place 0 into queue. The head is 0. The count is 1. The remaining is 1. The nextcount is 0. The line is empty text. The rows is an empty list of text.
Repeat while head is less than count.
The node is item head of queue. Add 1 to head. The piece is format whole number item node of values as text. If the length of line is more than 0, Place "," into line. Place piece into line. If item node of lefts is at least 0, Place item node of lefts into queue, add 1 to count, add 1 to nextcount. If item node of rights is at least 0, Place item node of rights into queue, add 1 to count, add 1 to nextcount. Subtract 1 from remaining. If remaining is 0, Place line into rows, set line to empty text, set remaining to nextcount, set nextcount to 0.

For each row in rows, show row.
```

**Expected stdout**

```text
3
9,20
15,7
```

## #0103 · Binary Tree Zigzag Level Order Traversal

**Medium · Breadth-First Search** · [Open in Playground](https://ponvasanthpon.github.io/TransCompilator/#problem=0103) · [Static page](https://ponvasanthpon.github.io/TransCompilator/problems/0103.html)

```text
Keep a shared values holding 3, 9, 20, 15, and 7. Keep a shared lefts holding 1, -1, 3, -1, and -1. Keep a shared rights holding 2, -1, 4, -1, and -1. Keep a shared rows as an empty list of text. Keep a shared rung as an empty list of text. Keep a shared line as empty text. Keep a shared depth of 0. Keep a shared backward of 0. Keep a shared rungcount of 0.
To stitch from spot (a whole number) with last (a whole number). If spot is more than last, return. The source is spot. If backward is 1, set source to last minus spot. If the length of line is more than 0, Place "," into line. Place item source of rung into line. Stitch from spot plus 1 with last.

To finish level. Set line to empty text. Set backward to 0. If depth modulo 2 is 1, set backward to 1. Stitch from 0 with rungcount minus 1. Place line into rows. Add 1 to depth.

For every filler from 0 to 19, Place "" into rung.

The queue is an empty list of whole numbers. Place 0 into queue. The head is 0. The count is 1. The remaining is 1. The nextcount is 0.
Repeat while head is less than count.
The node is item head of queue. Add 1 to head. The piece is format whole number item node of values as text. Set item rungcount of rung to piece. Add 1 to rungcount. If item node of lefts is at least 0, Place item node of lefts into queue, add 1 to count, add 1 to nextcount. If item node of rights is at least 0, Place item node of rights into queue, add 1 to count, add 1 to nextcount. Subtract 1 from remaining. If remaining is 0, finish level, set rungcount to 0, set remaining to nextcount, set nextcount to 0.

For each item in rows, show item.
```

**Expected stdout**

```text
3
20,9
15,7
```

## #0104 · Maximum Depth of Binary Tree

**Easy · Depth-First Search** · [Open in Playground](https://ponvasanthpon.github.io/TransCompilator/#problem=0104) · [Static page](https://ponvasanthpon.github.io/TransCompilator/problems/0104.html)

```text
Keep a shared values holding 3, 9, 20, 15, and 7. Keep a shared lefts holding 1, -1, 3, -1, and -1. Keep a shared rights holding 2, -1, 4, -1, and -1. Keep a shared deepest of 0.
To measure from node (a whole number) with depth (a whole number). If node is less than 0, return. If depth is more than deepest, set deepest to depth. Measure from item node of lefts with depth plus 1. Measure from item node of rights with depth plus 1.

Measure from 0 with 1. Show deepest.
```

**Expected stdout**

```text
3
```

## #0105 · Construct Binary Tree from Preorder and Inorder Traversal

**Medium · Array** · [Open in Playground](https://ponvasanthpon.github.io/TransCompilator/#problem=0105) · [Static page](https://ponvasanthpon.github.io/TransCompilator/problems/0105.html)

```text
Keep a shared preorder holding 3, 9, 20, 15, and 7. Keep a shared inorder holding 9, 3, 15, 20, and 7. Keep a shared values as an empty list of whole numbers. Keep a shared lefts as an empty list of whole numbers. Keep a shared rights as an empty list of whole numbers. Keep a shared preindex of 0. Keep a shared index of 0. Keep a shared parent of -1. Keep a shared side of 0.
To attach from instart (a whole number) with inend (a whole number). If instart is more than inend, return. The current is preindex. The root is item current of preorder. Add 1 to preindex. The slot is index. Add 1 to index. Place root into values. Place -1 into lefts. Place -1 into rights. The anchor is parent. If anchor is at least 0 and side is 0, set item anchor of lefts to slot. If anchor is at least 0 and side is 1, set item anchor of rights to slot. The split is instart. For every spot from instart to inend, if item spot of inorder is root, set split to spot. Set parent to slot. Set side to 0. Attach from instart with split minus 1. Set parent to slot. Set side to 1. Attach from split plus 1 with inend.

Attach from 0 with 4. Keep a shared order as an empty list of whole numbers.
To gather from node (a whole number). If node is less than 0, return. Gather from item node of lefts. Gather from item node of rights. Place node into order.

Gather from 0. For each node in order, show item node of values.
```

**Expected stdout**

```text
9
15
7
20
3
```

## #0106 · Construct Binary Tree from Inorder and Postorder Traversal

**Medium · Array** · [Open in Playground](https://ponvasanthpon.github.io/TransCompilator/#problem=0106) · [Static page](https://ponvasanthpon.github.io/TransCompilator/problems/0106.html)

```text
Keep a shared inorder holding 9, 3, 15, 20, and 7. Keep a shared postorder holding 9, 15, 7, 20, and 3. Keep a shared values as an empty list of whole numbers. Keep a shared lefts as an empty list of whole numbers. Keep a shared rights as an empty list of whole numbers. Keep a shared postindex of 0. Keep a shared index of 0. Keep a shared parent of -1. Keep a shared side of 0.
To attach from instart (a whole number) with inend (a whole number). If instart is more than inend, return. The current is postindex. The root is item current of postorder. Subtract 1 from postindex. The slot is index. Add 1 to index. Place root into values. Place -1 into lefts. Place -1 into rights. The anchor is parent. If anchor is at least 0 and side is 0, set item anchor of lefts to slot. If anchor is at least 0 and side is 1, set item anchor of rights to slot. The split is instart. For every spot from instart to inend, if item spot of inorder is root, set split to spot. Set parent to slot. Set side to 1. Attach from split plus 1 with inend. Set parent to slot. Set side to 0. Attach from instart with split minus 1.

Set postindex to 4. Attach from 0 with 4. Keep a shared order as an empty list of whole numbers.
To gather from node (a whole number). If node is less than 0, return. Place node into order. Gather from item node of lefts. Gather from item node of rights.

Gather from 0. For each node in order, show item node of values.
```

**Expected stdout**

```text
3
9
20
15
7
```

## #0107 · Binary Tree Level Order Traversal II

**Medium · Breadth-First Search** · [Open in Playground](https://ponvasanthpon.github.io/TransCompilator/#problem=0107) · [Static page](https://ponvasanthpon.github.io/TransCompilator/problems/0107.html)

```text
Keep a shared values holding 3, 9, 20, 15, and 7. Keep a shared lefts holding 1, -1, 3, -1, and -1. Keep a shared rights holding 2, -1, 4, -1, and -1.

The queue is an empty list of whole numbers. Place 0 into queue. The head is 0. The count is 1. The remaining is 1. The nextcount is 0. The line is empty text. The rows is an empty list of text.
Repeat while head is less than count.
The node is item head of queue. Add 1 to head. The piece is format whole number item node of values as text. If the length of line is more than 0, Place "," into line. Place piece into line. If item node of lefts is at least 0, Place item node of lefts into queue, add 1 to count, add 1 to nextcount. If item node of rights is at least 0, Place item node of rights into queue, add 1 to count, add 1 to nextcount. Subtract 1 from remaining. If remaining is 0, Place line into rows, set line to empty text, set remaining to nextcount, set nextcount to 0.

The lastrow is the last position of rows.
For every step from 0 to lastrow.
The source is lastrow minus step. Show item source of rows.
```

**Expected stdout**

```text
15,7
9,20
3
```

## #0108 · Convert Sorted Array to Binary Search Tree

**Easy · Array** · [Open in Playground](https://ponvasanthpon.github.io/TransCompilator/#problem=0108) · [Static page](https://ponvasanthpon.github.io/TransCompilator/problems/0108.html)

```text
Keep a shared numbers holding -10, -3, 0, 5, and 9. Keep a shared values as an empty list of whole numbers. Keep a shared lefts as an empty list of whole numbers. Keep a shared rights as an empty list of whole numbers. Keep a shared index of 0. Keep a shared parent of -1. Keep a shared side of 0.
To attach from low (a whole number) with high (a whole number). If low is more than high, return. The middle is the midpoint of low and high. The root is item middle of numbers. The slot is index. Add 1 to index. Place root into values. Place -1 into lefts. Place -1 into rights. The anchor is parent. If anchor is at least 0 and side is 0, set item anchor of lefts to slot. If anchor is at least 0 and side is 1, set item anchor of rights to slot. Set parent to slot. Set side to 0. Attach from low with middle minus 1. Set parent to slot. Set side to 1. Attach from middle plus 1 with high.

Attach from 0 with 4. For each value in values, show value.
```

**Expected stdout**

```text
0
-10
-3
5
9
```

## #0109 · Convert Sorted List to Binary Search Tree

**Medium · Tree** · [Open in Playground](https://ponvasanthpon.github.io/TransCompilator/#problem=0109) · [Static page](https://ponvasanthpon.github.io/TransCompilator/problems/0109.html)

```text
Keep a shared numbers holding -10, -3, 0, 5, and 9. Keep a shared values as an empty list of whole numbers. Keep a shared lefts as an empty list of whole numbers. Keep a shared rights as an empty list of whole numbers. Keep a shared index of 0. Keep a shared parent of -1. Keep a shared side of 0.
To shape from low (a whole number) with high (a whole number). If low is more than high, return. The middle is the midpoint of low and high. The root is item middle of numbers. The slot is index. Add 1 to index. Place root into values. Place -1 into lefts. Place -1 into rights. The anchor is parent. If anchor is at least 0 and side is 0, set item anchor of lefts to slot. If anchor is at least 0 and side is 1, set item anchor of rights to slot. Set parent to slot. Set side to 0. Shape from low with middle minus 1. Set parent to slot. Set side to 1. Shape from middle plus 1 with high.

Shape from 0 with 4. For each value in values, show value.
```

**Expected stdout**

```text
0
-10
-3
5
9
```

## #0110 · Balanced Binary Tree

**Easy · Depth-First Search** · [Open in Playground](https://ponvasanthpon.github.io/TransCompilator/#problem=0110) · [Static page](https://ponvasanthpon.github.io/TransCompilator/problems/0110.html)

```text
Keep a shared values holding 3, 9, 20, 15, and 7. Keep a shared lefts holding 1, -1, 3, -1, and -1. Keep a shared rights holding 2, -1, 4, -1, and -1.

The last is the last position of values. The size is last plus 1. The heights is a list of size zeros.
For every step from 0 to last.
The node is last minus step. The leftheight is 0. The rightheight is 0. The left is item node of lefts. The right is item node of rights. If left is at least 0, set leftheight to item left of heights. If right is at least 0, set rightheight to item right of heights. The tall is leftheight. If rightheight is more than tall, set tall to rightheight. Set item node of heights to tall plus 1.

The good is 1.
For every node from 0 to last.
The leftheight is 0. The rightheight is 0. The left is item node of lefts. The right is item node of rights. If left is at least 0, set leftheight to item left of heights. If right is at least 0, set rightheight to item right of heights. The difference is leftheight minus rightheight. If difference is more than 1, set good to 0. If difference is less than -1, set good to 0.

If good is 1, show true, otherwise show false.
```

**Expected stdout**

```text
true
```

## #0111 · Minimum Depth of Binary Tree

**Easy · Depth-First Search** · [Open in Playground](https://ponvasanthpon.github.io/TransCompilator/#problem=0111) · [Static page](https://ponvasanthpon.github.io/TransCompilator/problems/0111.html)

```text
Keep a shared values holding 3, 9, 20, 15, and 7. Keep a shared lefts holding 1, -1, 3, -1, and -1. Keep a shared rights holding 2, -1, 4, -1, and -1. Keep a shared best of 1000000.
To walk from node (a whole number) with depth (a whole number). If node is less than 0, return. The left is item node of lefts. The right is item node of rights. If left is -1 and right is -1, if depth is less than best, set best to depth, return. Walk from left with depth plus 1. Walk from right with depth plus 1.

Walk from 0 with 1. Show best.
```

**Expected stdout**

```text
2
```

## #0112 · Path Sum

**Easy · Depth-First Search** · [Open in Playground](https://ponvasanthpon.github.io/TransCompilator/#problem=0112) · [Static page](https://ponvasanthpon.github.io/TransCompilator/problems/0112.html)

```text
Keep a shared values holding 5, 4, 8, 11, -1, 13, 4, 7, 2, -1, -1, -1, and 1. Keep a shared lefts holding 1, 3, 5, 7, 9, 11, -1, -1, -1, -1, -1, -1, and -1. Keep a shared rights holding 2, 4, 6, 8, 10, 12, -1, -1, -1, -1, -1, -1, and -1. Keep a shared target of 0. Keep a shared found of 0. Set target to 22.
To seek from node (a whole number) with total (a whole number). If found is 1, return. If node is less than 0, return. The sum is total plus item node of values. The left is item node of lefts. The right is item node of rights. If left is -1 and right is -1 and sum is target, set found to 1, return. Seek from left with sum. Seek from right with sum.

Seek from 0 with 0. If found is 1, show true, otherwise show false.
```

**Expected stdout**

```text
true
```

## #0113 · Path Sum II

**Medium · Depth-First Search** · [Open in Playground](https://ponvasanthpon.github.io/TransCompilator/#problem=0113) · [Static page](https://ponvasanthpon.github.io/TransCompilator/problems/0113.html)

```text
Keep a shared values holding 5, 4, 8, 11, 6, 4, 7, 2, 5, and 1. Keep a shared lefts holding 1, 3, 5, 6, -1, 8, -1, -1, -1, and -1. Keep a shared rights holding 2, 4, -1, 7, -1, 9, -1, -1, -1, and -1. Keep a shared path as an empty list of whole numbers. Keep a shared answers as an empty list of text. Keep a shared target of 0. Keep a shared line as empty text. Set target to 22.
To render from spot (a whole number) with last (a whole number). If spot is more than last, return. If the length of line is more than 0, Place "," into line. The piece is format whole number item spot of path as text. Place piece into line. Render from spot plus 1 with last.

To store answer. Set line to empty text. The lastpath is the last position of path. Render from 0 with lastpath. The copy is a copy of line. Place copy into answers.

To seek from node (a whole number) with total (a whole number). If node is less than 0, return. The sum is total plus item node of values. Place item node of values into path. The left is item node of lefts. The right is item node of rights. If left is -1 and right is -1 and sum is target, store answer. If left is at least 0, seek from left with sum. If right is at least 0, seek from right with sum. Remove the last item from path.

Seek from 0 with 0. For each answer in answers, show answer.
```

**Expected stdout**

```text
5,4,11,2
5,8,4,5
```

## #0114 · Flatten Binary Tree to Linked List

**Medium · Depth-First Search** · [Open in Playground](https://ponvasanthpon.github.io/TransCompilator/#problem=0114) · [Static page](https://ponvasanthpon.github.io/TransCompilator/problems/0114.html)

```text
Keep a shared values holding 1, 2, 5, 3, 4, and 6. Keep a shared lefts holding 1, 3, -1, -1, -1, and -1. Keep a shared rights holding 2, 4, 5, -1, -1, and -1. Keep a shared order as an empty list of whole numbers.
To gather from node (a whole number). If node is less than 0, return. Place node into order. Gather from item node of lefts. Gather from item node of rights.

Gather from 0. For each node in order, show item node of values.
```

**Expected stdout**

```text
1
2
3
4
5
6
```

## #0115 · Distinct Subsequences

**Hard · String** · [Open in Playground](https://ponvasanthpon.github.io/TransCompilator/#problem=0115) · [Static page](https://ponvasanthpon.github.io/TransCompilator/problems/0115.html)

```text
Keep a shared source as empty text. Keep a shared target as empty text. Keep a shared dp as an empty list of whole numbers. Place "rabbbit" into source. Place "rabbit" into target. The targetsize is 6.
For every spot from 0 to 6.
Place 0 into dp.

Set item 0 of dp to 1.
To scan from spot (a whole number) with symbol (a whole number). If spot is less than 1, return. If character (spot minus 1) of target is symbol, set item spot of dp to item spot of dp plus item (spot minus 1) of dp. Scan from spot minus 1 with symbol.

The last is the last position of source.
For every position from 0 to last.
Scan from targetsize with character position of source.

Show item targetsize of dp.
```

**Expected stdout**

```text
3
```

## #0116 · Populating Next Right Pointers in Each Node

**Medium · Depth-First Search** · [Open in Playground](https://ponvasanthpon.github.io/TransCompilator/#problem=0116) · [Static page](https://ponvasanthpon.github.io/TransCompilator/problems/0116.html)

```text
Keep a shared values holding 1, 2, 3, 4, 5, 6, and 7. Keep a shared lefts holding 1, 3, 5, -1, -1, -1, and -1. Keep a shared rights holding 2, 4, 6, -1, -1, -1, and -1.

The nexts is an empty list of whole numbers. For every spot from 0 to 6, Place -1 into nexts. The queue is an empty list of whole numbers. Place 0 into queue. The head is 0. The count is 1. The remaining is 1. The nextcount is 0. The previous is -1.
Repeat while head is less than count.
The node is item head of queue. Add 1 to head. If previous is at least 0, set item previous of nexts to node. Set previous to node. If item node of lefts is at least 0, Place item node of lefts into queue, add 1 to count, add 1 to nextcount. If item node of rights is at least 0, Place item node of rights into queue, add 1 to count, add 1 to nextcount. Subtract 1 from remaining. If remaining is 0, set previous to -1, set remaining to nextcount, set nextcount to 0.

For every node from 0 to 6.
The line is format whole number item node of values as text. Place " " into line. The next is item node of nexts. If next is at least 0, Place format whole number item next of values as text into line, otherwise Place "-1" into line. Show line.
```

**Expected stdout**

```text
1 -1
2 3
3 -1
4 5
5 6
6 7
7 -1
```

## #0117 · Populating Next Right Pointers in Each Node II

**Medium · Depth-First Search** · [Open in Playground](https://ponvasanthpon.github.io/TransCompilator/#problem=0117) · [Static page](https://ponvasanthpon.github.io/TransCompilator/problems/0117.html)

```text
Keep a shared values holding 1, 2, 3, 4, 5, and 7. Keep a shared lefts holding 1, 3, -1, -1, -1, and -1. Keep a shared rights holding 2, 4, 5, -1, -1, and -1.

The nexts is an empty list of whole numbers. For every spot from 0 to 5, Place -1 into nexts. The queue is an empty list of whole numbers. Place 0 into queue. The head is 0. The count is 1. The remaining is 1. The nextcount is 0. The previous is -1.
Repeat while head is less than count.
The node is item head of queue. Add 1 to head. If previous is at least 0, set item previous of nexts to node. Set previous to node. If item node of lefts is at least 0, Place item node of lefts into queue, add 1 to count, add 1 to nextcount. If item node of rights is at least 0, Place item node of rights into queue, add 1 to count, add 1 to nextcount. Subtract 1 from remaining. If remaining is 0, set previous to -1, set remaining to nextcount, set nextcount to 0.

For every node from 0 to 5.
The line is format whole number item node of values as text. Place " " into line. The next is item node of nexts. If next is at least 0, Place format whole number item next of values as text into line, otherwise Place "-1" into line. Show line.
```

**Expected stdout**

```text
1 -1
2 3
3 -1
4 5
5 7
7 -1
```

## #0118 · Pascal's Triangle

**Easy · Array** · [Open in Playground](https://ponvasanthpon.github.io/TransCompilator/#problem=0118) · [Static page](https://ponvasanthpon.github.io/TransCompilator/problems/0118.html)

```text
Keep a shared previous as an empty list of whole numbers. Keep a shared current as an empty list of whole numbers. Keep a shared line as empty text.
For every spot from 0 to 4.
Place 0 into previous. Place 0 into current.

To shape from spot (a whole number) with level (a whole number). If spot is more than level, return. The value is 1. If spot is more than 0 and spot is less than level, set value to item (spot minus 1) of previous plus item spot of previous. Set item spot of current to value. If spot is more than 0, Place "," into line. Place format whole number value as text into line. Shape from spot plus 1 with level.

To carry from spot (a whole number) with level (a whole number). If spot is more than level, return. Set item spot of previous to item spot of current. Carry from spot plus 1 with level.

For every level from 0 to 4.
Set line to empty text. Shape from 0 with level. Show line. Carry from 0 with level.
```

**Expected stdout**

```text
1
1,1
1,2,1
1,3,3,1
1,4,6,4,1
```

## #0119 · Pascal's Triangle II

**Easy · Array** · [Open in Playground](https://ponvasanthpon.github.io/TransCompilator/#problem=0119) · [Static page](https://ponvasanthpon.github.io/TransCompilator/problems/0119.html)

```text
Keep a shared previous as an empty list of whole numbers. Keep a shared current as an empty list of whole numbers. Keep a shared line as empty text.
For every spot from 0 to 4.
Place 0 into previous. Place 0 into current.

To shape from spot (a whole number) with level (a whole number). If spot is more than level, return. The value is 1. If spot is more than 0 and spot is less than level, set value to item (spot minus 1) of previous plus item spot of previous. Set item spot of current to value. If spot is more than 0, Place "," into line. Place format whole number value as text into line. Shape from spot plus 1 with level.

To carry from spot (a whole number) with level (a whole number). If spot is more than level, return. Set item spot of previous to item spot of current. Carry from spot plus 1 with level.

For every level from 0 to 3.
Set line to empty text. Shape from 0 with level. Carry from 0 with level.

Show line.
```

**Expected stdout**

```text
1,3,3,1
```

## #0120 · Triangle

**Medium · Array** · [Open in Playground](https://ponvasanthpon.github.io/TransCompilator/#problem=0120) · [Static page](https://ponvasanthpon.github.io/TransCompilator/problems/0120.html)

```text
The values is a list of 2, 3, 4, 6, 5, 7, 4, 1, 8, and 3. The starts is a list of 0, 1, 3, and 6. The success as an empty list of whole numbers. Keep a shared valueslist holding 2, 3, 4, 6, 5, 7, 4, 1, 8, and 3. Keep a shared startslist holding 0, 1, 3, and 6. The dp is a list of 10 zeros.
For every spot from 6 to 9.
Set item spot of dp to item spot of valueslist.

The rows is a list of 2, 2, 2, 1, 1, and 0. The columns is a list of 0, 1, 2, 0, 1, and 0.
For every step from 0 to 5.
The row is item step of rows. The column is item step of columns. The base is item row of startslist. The below is item (row plus 1) of startslist. The here is item (base plus column) of valueslist. The first is item (below plus column) of dp. The second is item (below plus column plus 1) of dp. The small is first. If second is less than small, set small to second. Set item (base plus column) of dp to here plus small.

Show item 0 of dp.
```

**Expected stdout**

```text
11
```

## #0121 · Best Time to Buy and Sell Stock

**Easy · Array** · [Open in Playground](https://ponvasanthpon.github.io/TransCompilator/#problem=0121) · [Static page](https://ponvasanthpon.github.io/TransCompilator/problems/0121.html)

```text
The prices is a list of 7, 1, 5, 3, 6, and 4. The last is the last position of prices. The cheapest is item 0 of prices. The best is 0.
For every spot from 1 to last.
The price is item spot of prices. The gain is price minus cheapest. If gain is more than best, set best to gain. If price is less than cheapest, set cheapest to price.

Show best.
```

**Expected stdout**

```text
5
```

## #0122 · Best Time to Buy and Sell Stock II

**Medium · Array** · [Open in Playground](https://ponvasanthpon.github.io/TransCompilator/#problem=0122) · [Static page](https://ponvasanthpon.github.io/TransCompilator/problems/0122.html)

```text
The prices is a list of 7, 1, 5, 3, 6, and 4. The last is the last position of prices. The profit is 0.
For every spot from 1 to last.
The gain is item spot of prices minus item (spot minus 1) of prices. If gain is more than 0, add gain to profit.

Show profit.
```

**Expected stdout**

```text
7
```

## #0123 · Best Time to Buy and Sell Stock III

**Hard · Array** · [Open in Playground](https://ponvasanthpon.github.io/TransCompilator/#problem=0123) · [Static page](https://ponvasanthpon.github.io/TransCompilator/problems/0123.html)

```text
The prices is a list of 3, 3, 5, 0, 0, 3, 1, and 4. The last is the last position of prices. The firstbuy is -1000000. The firstsell is 0. The secondbuy is -1000000. The secondsell is 0.
For every spot from 0 to last.
The price is item spot of prices. The trial is 0 minus price. If trial is more than firstbuy, set firstbuy to trial. The trial is firstbuy plus price. If trial is more than firstsell, set firstsell to trial. The trial is firstsell minus price. If trial is more than secondbuy, set secondbuy to trial. The trial is secondbuy plus price. If trial is more than secondsell, set secondsell to trial.

Show secondsell.
```

**Expected stdout**

```text
6
```

## #0124 · Binary Tree Maximum Path Sum

**Hard · Dynamic Programming** · [Open in Playground](https://ponvasanthpon.github.io/TransCompilator/#problem=0124) · [Static page](https://ponvasanthpon.github.io/TransCompilator/problems/0124.html)

```text
Keep a shared values holding -10, 9, 20, -1, -1, 15, and 7. Keep a shared lefts holding 1, 3, 5, -1, -1, -1, and -1. Keep a shared rights holding 2, 4, 6, -1, -1, -1, and -1.

The last is the last position of values. The size is last plus 1. The gains is a list of size zeros. The best is 0.
For every step from 0 to last.
The node is last minus step. The value is item node of values.
If value is at least 0.
The leftgain is 0. The rightgain is 0. The left is item node of lefts. The right is item node of rights. If left is at least 0, set leftgain to item left of gains. If right is at least 0, set rightgain to item right of gains. If leftgain is less than 0, set leftgain to 0. If rightgain is less than 0, set rightgain to 0. The through is value plus leftgain plus rightgain. If through is more than best, set best to through. The gain is value. If leftgain is more than rightgain and leftgain is more than 0, set gain to value plus leftgain. If rightgain is at least leftgain and rightgain is more than 0, set gain to value plus rightgain. Set item node of gains to gain.

Show best.
```

**Expected stdout**

```text
42
```

## #0125 · Valid Palindrome

**Easy · String** · [Open in Playground](https://ponvasanthpon.github.io/TransCompilator/#problem=0125) · [Static page](https://ponvasanthpon.github.io/TransCompilator/problems/0125.html)

```text
Keep a shared upper as empty text. Keep a shared lower as empty text. Keep a shared clean as empty text. Place "ABCDEFGHIJKLMNOPQRSTUVWXYZ" into upper. Place "abcdefghijklmnopqrstuvwxyz" into lower.
To filter from spot (a whole number) with symbol (a whole number). If symbol is between "0" and "9", Place symbol into clean, return. If spot is more than 25, return. If symbol is character spot of lower, Place symbol into clean, return. If symbol is character spot of upper, Place character spot of lower into clean, return. Filter from spot plus 1 with symbol.

The word is "A man, a plan, a canal: Panama". The last is the last position of word.
For every position from 0 to last.
Filter from 0 with character position of word.

The left is 0. The right is the last position of clean. The valid is 1.
Repeat while left is less than right.
If character left of clean is not character right of clean, set valid to 0. Add 1 to left. Subtract 1 from right.

If valid is 1, show true, otherwise show false.
```

**Expected stdout**

```text
true
```

## #0126 · Word Ladder II

**Hard · String** · [Open in Playground](https://ponvasanthpon.github.io/TransCompilator/#problem=0126) · [Static page](https://ponvasanthpon.github.io/TransCompilator/problems/0126.html)

```text
Keep a shared words holding "hit", "hot", "dot", "dog", "lot", "log", and "cog". Keep a shared firstword as empty text. Keep a shared secondword as empty text. Keep a shared apart of 0. Keep a shared used as an empty list of whole numbers. Keep a shared path as an empty list of whole numbers. Keep a shared answers as an empty list of text. Keep a shared line as empty text. Keep a shared depth of 0.
For every spot from 0 to 6.
Place 0 into used.

To compare from spot (a whole number) with last (a whole number). If spot is more than last, return. If character spot of firstword is not character spot of secondword, add 1 to apart. Compare from spot plus 1 with last.

To render from spot (a whole number) with last (a whole number). If spot is more than last, return. If spot is more than 0, Place " " into line. The node is item spot of path. Place item node of words into line. Render from spot plus 1 with last.

To store path. Set line to empty text. The lastpath is the last position of path. Render from 0 with lastpath. The copy is a copy of line. Place copy into answers.

To extend from current (a whole number) with candidate (a whole number). Set item candidate of used to 1. Place candidate into path. Add 1 to depth. If candidate is 6 and depth is 4, store path. If candidate is not 6 and depth is less than 4, walk from candidate with 0. Subtract 1 from depth. Remove the last item from path. Set item candidate of used to 0.

To walk from current (a whole number) with candidate (a whole number). If depth is 4, return. If candidate is more than 6, return. If item candidate of used is 1, walk from current with candidate plus 1, return. Set firstword to item current of words. Set secondword to item candidate of words. Set apart to 0. Compare from 0 with 2. If apart is 1, extend from current with candidate. Walk from current with candidate plus 1.

Set item 0 of used to 1. Place 0 into path. Walk from 0 with 0. For each answer in answers, show answer.
```

**Expected stdout**

```text
hit hot dot dog cog
hit hot lot log cog
```

## #0127 · Word Ladder

**Hard · String** · [Open in Playground](https://ponvasanthpon.github.io/TransCompilator/#problem=0127) · [Static page](https://ponvasanthpon.github.io/TransCompilator/problems/0127.html)

```text
Keep a shared words holding "hit", "hot", "dot", "dog", "lot", "log", and "cog". Keep a shared firstword as empty text. Keep a shared secondword as empty text. Keep a shared apart of 0.
To compare from spot (a whole number) with last (a whole number). If spot is more than last, return. If character spot of firstword is not character spot of secondword, add 1 to apart. Compare from spot plus 1 with last.

Keep a shared seen as an empty list of whole numbers. Keep a shared distance as an empty list of whole numbers. Keep a shared queue as an empty list of whole numbers. Keep a shared count of 0.
For every spot from 0 to 6.
Place 0 into seen. Place 0 into distance.

Place 0 into queue. Set item 0 of seen to 1. Set item 0 of distance to 1. The head is 0. Set count to 1.
To expand from current (a whole number) with candidate (a whole number). If candidate is more than 6, return. If item candidate of seen is 1, expand from current with candidate plus 1, return. Set firstword to item current of words. Set secondword to item candidate of words. Set apart to 0. Compare from 0 with 2. If apart is 1, set item candidate of seen to 1, set item candidate of distance to item current of distance plus 1, Place candidate into queue, add 1 to count. Expand from current with candidate plus 1.

Repeat while head is less than count.
The current is item head of queue. Add 1 to head. Expand from current with 1.

If item 6 of seen is 1, show item 6 of distance, otherwise show 0.
```

**Expected stdout**

```text
5
```

## #0128 · Longest Consecutive Sequence

**Medium · Array** · [Open in Playground](https://ponvasanthpon.github.io/TransCompilator/#problem=0128) · [Static page](https://ponvasanthpon.github.io/TransCompilator/problems/0128.html)

```text
The numbers is a list of 100, 4, 200, 1, 3, and 2. Sort numbers. The last is the last position of numbers. The best is 1. The run is 1.
For every spot from 1 to last.
The current is item spot of numbers. The before is item (spot minus 1) of numbers. If current is before plus 1, add 1 to run. If current is not before and current is not before plus 1, set run to 1. If run is more than best, set best to run.

Show best.
```

**Expected stdout**

```text
4
```

## #0129 · Sum Root to Leaf Numbers

**Medium · Depth-First Search** · [Open in Playground](https://ponvasanthpon.github.io/TransCompilator/#problem=0129) · [Static page](https://ponvasanthpon.github.io/TransCompilator/problems/0129.html)

```text
Keep a shared values holding 1, 2, and 3. Keep a shared lefts holding 1, -1, and -1. Keep a shared rights holding 2, -1, and -1. Keep a shared total of 0.
To walk from node (a whole number) with value (a whole number). If node is less than 0, return. The current is value times 10 plus item node of values. The left is item node of lefts. The right is item node of rights. If left is -1 and right is -1, add current to total, return. Walk from left with current. Walk from right with current.

Walk from 0 with 0. Show total.
```

**Expected stdout**

```text
25
```

## #0130 · Surrounded Regions

**Medium · Array** · [Open in Playground](https://ponvasanthpon.github.io/TransCompilator/#problem=0130) · [Static page](https://ponvasanthpon.github.io/TransCompilator/problems/0130.html)

```text
Keep a shared board holding 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 0, 1, and 1. Keep a shared safe as an empty list of whole numbers.
For every spot from 0 to 15.
Place 0 into safe.

The queue is an empty list of whole numbers. The count is 0. The head is 0.
For every spot from 0 to 15.
The row is spot divided by 4. The column is spot modulo 4.
If row is 0 or row is 3 or column is 0 or column is 3.
If item spot of board is 0 and item spot of safe is 0, set item spot of safe to 1, Place spot into queue, add 1 to count.

Repeat while head is less than count.
The node is item head of queue. Add 1 to head. The row is node divided by 4. The column is node modulo 4. If row is more than 0 and item (node minus 4) of board is 0 and item (node minus 4) of safe is 0, set item (node minus 4) of safe to 1, Place (node minus 4) into queue, add 1 to count. If row is less than 3 and item (node plus 4) of board is 0 and item (node plus 4) of safe is 0, set item (node plus 4) of safe to 1, Place (node plus 4) into queue, add 1 to count. If column is more than 0 and item (node minus 1) of board is 0 and item (node minus 1) of safe is 0, set item (node minus 1) of safe to 1, Place (node minus 1) into queue, add 1 to count. If column is less than 3 and item (node plus 1) of board is 0 and item (node plus 1) of safe is 0, set item (node plus 1) of safe to 1, Place (node plus 1) into queue, add 1 to count.

Keep a shared line as empty text.
To render from spot (a whole number) with last (a whole number). If spot is more than last, return. If item spot of board is 1 or item spot of safe is 0, Place "X" into line, otherwise Place "O" into line. Render from spot plus 1 with last.

For every row from 0 to 3.
Set line to empty text. The start is row times 4. The finish is start plus 3. Render from start with finish. Show line.
```

**Expected stdout**

```text
XXXX
XXXX
XXXX
XOXX
```

## #0131 · Palindrome Partitioning

**Medium · String** · [Open in Playground](https://ponvasanthpon.github.io/TransCompilator/#problem=0131) · [Static page](https://ponvasanthpon.github.io/TransCompilator/problems/0131.html)

```text
Keep a shared word as empty text. Place "aab" into word. Keep a shared path as an empty list of text. Keep a shared answers as an empty list of text. Keep a shared pal of 1.
To test from left (a whole number) with right (a whole number). If left is at least right, return. If character left of word is not character right of word, set pal to 0, return. Test from left plus 1 with right minus 1.

To store answer. The line is join path with ",". Place line into answers.

To extend from start (a whole number) with finish (a whole number). The piece is the slice of word from start to finish plus 1. Place piece into path. If finish is 2, store answer. If finish is less than 2, scan from finish plus 1 with finish plus 1. Remove the last item from path.

To scan from start (a whole number) with finish (a whole number). If finish is more than 2, return. Set pal to 1. Test from start with finish. If pal is 1, extend from start with finish. Scan from start with finish plus 1.

Scan from 0 with 0. For each answer in answers, show answer.
```

**Expected stdout**

```text
a,a,b
aa,b
```

## #0132 · Palindrome Partitioning II

**Hard · String** · [Open in Playground](https://ponvasanthpon.github.io/TransCompilator/#problem=0132) · [Static page](https://ponvasanthpon.github.io/TransCompilator/problems/0132.html)

```text
Keep a shared word as empty text. Place "aab" into word. Keep a shared cuts as an empty list of whole numbers.
For every spot from 0 to 3.
Place spot into cuts.

Keep a shared pal of 1.
To test from left (a whole number) with right (a whole number). If left is at least right, return. If character left of word is not character right of word, set pal to 0, return. Test from left plus 1 with right minus 1.

To improve from finish (a whole number) with start (a whole number). The candidate is item start of cuts plus 1. If candidate is less than item finish of cuts, set item finish of cuts to candidate.

To relax from finish (a whole number) with start (a whole number). If start is less than 0, return. Set pal to 1. Test from start with finish minus 1. If pal is 1, improve from finish with start. Relax from finish with start minus 1.

For every finish from 1 to 3.
Relax from finish with finish minus 1.

Show item 3 of cuts minus 1.
```

**Expected stdout**

```text
1
```

## #0133 · Clone Graph

**Medium · Depth-First Search** · [Open in Playground](https://ponvasanthpon.github.io/TransCompilator/#problem=0133) · [Static page](https://ponvasanthpon.github.io/TransCompilator/problems/0133.html)

```text
Keep a shared edges holding 1, 3, 0, 2, 1, 3, 0, and 2. Keep a shared starts holding 0, 2, 4, and 6. Keep a shared counts holding 2, 2, 2, and 2. Keep a shared copyedges as an empty list of whole numbers. Keep a shared copystarts as an empty list of whole numbers. Keep a shared copycounts as an empty list of whole numbers.
For each edge in edges.
Place edge into copyedges.

For each start in starts.
Place start into copystarts.

For each count in counts.
Place count into copycounts.

Keep a shared line as empty text.
To list from node (a whole number) with spot (a whole number). If spot is more than item node of copycounts, return. If spot is more than 0, Place " " into line. The base is item node of copystarts. The target is item (base plus spot minus 1) of copyedges. Place format whole number target plus 1 as text into line. List from node with spot plus 1.

For every node from 0 to 3.
Set line to format whole number node plus 1 as text. List from node with 1. Show line.
```

**Expected stdout**

```text
1 2 4
2 1 3
3 2 4
4 1 3
```

## #0134 · Gas Station

**Medium · Array** · [Open in Playground](https://ponvasanthpon.github.io/TransCompilator/#problem=0134) · [Static page](https://ponvasanthpon.github.io/TransCompilator/problems/0134.html)

```text
The gas is a list of 1, 2, 3, 4, and 5. The cost is a list of 3, 4, 5, 1, and 2. The last is the last position of gas. The total is 0. The tank is 0. The start is 0.
For every spot from 0 to last.
The gain is item spot of gas minus item spot of cost. Add gain to total. Add gain to tank. If tank is less than 0, set start to spot plus 1, set tank to 0.

If total is at least 0, show start, otherwise show -1.
```

**Expected stdout**

```text
3
```

## #0135 · Candy

**Hard · Array** · [Open in Playground](https://ponvasanthpon.github.io/TransCompilator/#problem=0135) · [Static page](https://ponvasanthpon.github.io/TransCompilator/problems/0135.html)

```text
The ratings is a list of 1, 0, and 2. The last is the last position of ratings. The candies is an empty list of whole numbers.
For every spot from 0 to last.
Place 1 into candies.

For every spot from 1 to last.
If item spot of ratings is more than item (spot minus 1) of ratings, set item spot of candies to item (spot minus 1) of candies plus 1.

For every step from 0 to last.
The spot is last minus step.
If spot is less than last and item spot of ratings is more than item (spot plus 1) of ratings.
If item spot of candies is at most item (spot plus 1) of candies, set item spot of candies to item (spot plus 1) of candies plus 1.

The total is 0.
For each candy in candies.
Add candy to total.

Show total.
```

**Expected stdout**

```text
5
```

## #0136 · Single Number

**Easy · Array** · [Open in Playground](https://ponvasanthpon.github.io/TransCompilator/#problem=0136) · [Static page](https://ponvasanthpon.github.io/TransCompilator/problems/0136.html)

```text
The numbers is a list of 4, 1, 2, 1, and 2. The answer is 0.
For each value in numbers.
Set answer to exclusive or of answer and value.

Show answer.
```

**Expected stdout**

```text
4
```

## #0137 · Single Number II

**Medium · Array** · [Open in Playground](https://ponvasanthpon.github.io/TransCompilator/#problem=0137) · [Static page](https://ponvasanthpon.github.io/TransCompilator/problems/0137.html)

```text
Keep a shared numbers holding 2, 2, 3, and 2. Keep a shared occurrences of 0. Keep a shared lastindex of 3.
To count from spot (a whole number) with target (a whole number). If spot is more than lastindex, return. If item spot of numbers is target, add 1 to occurrences. Count from spot plus 1 with target.

For each candidate in numbers.
Set occurrences to 0. Count from 0 with candidate. If occurrences is 1, show candidate.
```

**Expected stdout**

```text
3
```

## #0138 · Copy List with Random Pointer

**Medium · Linked List** · [Open in Playground](https://ponvasanthpon.github.io/TransCompilator/#problem=0138) · [Static page](https://ponvasanthpon.github.io/TransCompilator/problems/0138.html)

```text
The values is a list of 7, 13, 11, 10, and 1. The nexts is a list of 1, 2, 3, 4, and -1. The randoms is a list of -1, 0, 4, 2, and 0. The copyvalues is an empty list of whole numbers. The copynexts is an empty list of whole numbers. The copyrandoms is an empty list of whole numbers.
For each value in values.
Place value into copyvalues.

For each next in nexts.
Place next into copynexts.

For each random in randoms.
Place random into copyrandoms.

For every node from 0 to 4.
The line is format whole number item node of copyvalues as text. Place " " into line. The random is item node of copyrandoms. If random is at least 0, Place format whole number item random of copyvalues as text into line, otherwise Place "-1" into line. Show line.
```

**Expected stdout**

```text
7 -1
13 7
11 1
10 11
1 7
```

## #0139 · Word Break

**Medium · Array** · [Open in Playground](https://ponvasanthpon.github.io/TransCompilator/#problem=0139) · [Static page](https://ponvasanthpon.github.io/TransCompilator/problems/0139.html)

```text
Keep a shared source as empty text. Keep a shared words as an empty list of text. Keep a shared lengths as an empty list of whole numbers. Place "leetcode" into source. Place "leet" into words. Place "code" into words. Place 4 into lengths. Place 4 into lengths. Keep a shared dp as an empty list of whole numbers.
For every spot from 0 to 8.
Place 0 into dp.

Set item 0 of dp to 1.
To check from finish (a whole number) with spot (a whole number). If spot is more than 1, return. The size is item spot of lengths. If size is more than finish, check from finish with spot plus 1, return. The start is finish minus size. The piece is the slice of source from start to finish. The word is item spot of words. If piece does not match word, check from finish with spot plus 1, return. If item start of dp is 1, set item finish of dp to 1. Check from finish with spot plus 1.

For every finish from 1 to 8.
Check from finish with 0.

If item 8 of dp is 1, show true, otherwise show false.
```

**Expected stdout**

```text
true
```

## #0140 · Word Break II

**Hard · Array** · [Open in Playground](https://ponvasanthpon.github.io/TransCompilator/#problem=0140) · [Static page](https://ponvasanthpon.github.io/TransCompilator/problems/0140.html)

```text
Keep a shared text as empty text. Keep a shared words as an empty list of text. Keep a shared lengths as an empty list of whole numbers. Keep a shared path as an empty list of text. Keep a shared answers as an empty list of text. Keep a shared textsize of 0. Place "catsanddog" into text. Place "cats" into words. Place "cat" into words. Place "and" into words. Place "sand" into words. Place "dog" into words. Place 4 into lengths. Place 3 into lengths. Place 3 into lengths. Place 4 into lengths. Place 3 into lengths. Set textsize to 10.
To store answer. The line is join path with " ". Place line into answers.

To try from start (a whole number) with spot (a whole number). If start is textsize, store answer, return. If spot is more than 4, return. The size is item spot of lengths. If start plus size is more than textsize, try from start with spot plus 1, return. The finish is start plus size. The piece is the slice of text from start to finish. If piece does not match item spot of words, try from start with spot plus 1, return. Place item spot of words into path. Try from finish with 0. Remove the last item from path. Try from start with spot plus 1.

Try from 0 with 0. For each answer in answers, show answer.
```

**Expected stdout**

```text
cats and dog
cat sand dog
```

## #0141 · Linked List Cycle

**Easy · Two Pointers** · [Open in Playground](https://ponvasanthpon.github.io/TransCompilator/#problem=0141) · [Static page](https://ponvasanthpon.github.io/TransCompilator/problems/0141.html)

```text
The values is a list of 3, 2, 0, and -4. The nexts is a list of 1, 2, 3, and 1. The visited is a list of 4 zeros. The node is 0.
Repeat while node is at least 0 and item node of visited is 0.
Set item node of visited to 1. Set node to item node of nexts.

If node is at least 0, show true, otherwise show false.
```

**Expected stdout**

```text
true
```

## #0142 · Linked List Cycle II

**Medium · Two Pointers** · [Open in Playground](https://ponvasanthpon.github.io/TransCompilator/#problem=0142) · [Static page](https://ponvasanthpon.github.io/TransCompilator/problems/0142.html)

```text
The values is a list of 3, 2, 0, and -4. The nexts is a list of 1, 2, 3, and 1. The visited is a list of 4 zeros. The order is an empty list of whole numbers. The node is 0.
Repeat while node is at least 0 and item node of visited is 0.
Set item node of visited to 1. Place node into order. Set node to item node of nexts.

If node is less than 0, show -1, otherwise show node.
```

**Expected stdout**

```text
1
```

## #0143 · Reorder List

**Medium · Stack** · [Open in Playground](https://ponvasanthpon.github.io/TransCompilator/#problem=0143) · [Static page](https://ponvasanthpon.github.io/TransCompilator/problems/0143.html)

```text
The values is a list of 1, 2, 3, and 4. The left is 0. The right is 3. The take is 0. The result is an empty list of whole numbers.
Repeat while left is at most right.
If take is 0, Place item left of values into result, add 1 to left. If take is 1, Place item right of values into result, subtract 1 from right. Set take to 1 minus take.

For each value in result, show value.
```

**Expected stdout**

```text
1
4
2
3
```

## #0144 · Binary Tree Preorder Traversal

**Easy · Depth-First Search** · [Open in Playground](https://ponvasanthpon.github.io/TransCompilator/#problem=0144) · [Static page](https://ponvasanthpon.github.io/TransCompilator/problems/0144.html)

```text
Keep a shared values holding 1, 2, and 3. Keep a shared lefts holding -1, -1, and -1. Keep a shared rights holding 1, 2, and -1. Keep a shared order as an empty list of whole numbers.
To gather from node (a whole number). If node is less than 0, return. Place node into order. Gather from item node of lefts. Gather from item node of rights.

Gather from 0. For each node in order, show item node of values.
```

**Expected stdout**

```text
1
2
3
```

## #0145 · Binary Tree Postorder Traversal

**Easy · Depth-First Search** · [Open in Playground](https://ponvasanthpon.github.io/TransCompilator/#problem=0145) · [Static page](https://ponvasanthpon.github.io/TransCompilator/problems/0145.html)

```text
Keep a shared values holding 1, 2, and 3. Keep a shared lefts holding -1, -1, and -1. Keep a shared rights holding 1, 2, and -1. Keep a shared order as an empty list of whole numbers.
To gather from node (a whole number). If node is less than 0, return. Gather from item node of lefts. Gather from item node of rights. Place node into order.

Gather from 0. For each node in order, show item node of values.
```

**Expected stdout**

```text
3
2
1
```

## #0147 · Insertion Sort List

**Medium · Sorting** · [Open in Playground](https://ponvasanthpon.github.io/TransCompilator/#problem=0147) · [Static page](https://ponvasanthpon.github.io/TransCompilator/problems/0147.html)

```text
Keep a shared values holding 4, 2, 1, and 3.
To shift from spot (a whole number) with key (a whole number). If spot is less than 0, set item 0 of values to key, return. If item spot of values is at most key, set item (spot plus 1) of values to key, return. Set item (spot plus 1) of values to item spot of values. Shift from spot minus 1 with key.

The last is 3.
For every spot from 1 to last.
The key is item spot of values. Shift from spot minus 1 with key.

For each value in values, show value.
```

**Expected stdout**

```text
1
2
3
4
```

## #0148 · Sort List

**Medium · Sorting** · [Open in Playground](https://ponvasanthpon.github.io/TransCompilator/#problem=0148) · [Static page](https://ponvasanthpon.github.io/TransCompilator/problems/0148.html)

```text
Keep a shared values holding 4, 2, 1, and 3.
To place from spot (a whole number) with key (a whole number). If spot is less than 0, set item 0 of values to key, return. If item spot of values is at most key, set item (spot plus 1) of values to key, return. Set item (spot plus 1) of values to item spot of values. Place from spot minus 1 with key.

The last is 3.
For every spot from 1 to last.
The key is item spot of values. Place from spot minus 1 with key.

For each value in values, show value.
```

**Expected stdout**

```text
1
2
3
4
```

## #0149 · Max Points on a Line

**Hard · Array** · [Open in Playground](https://ponvasanthpon.github.io/TransCompilator/#problem=0149) · [Static page](https://ponvasanthpon.github.io/TransCompilator/problems/0149.html)

```text
Keep a shared xs as an empty list of whole numbers. Keep a shared ys as an empty list of whole numbers. Place 1 into xs. Place 2 into xs. Place 3 into xs. Place 1 into ys. Place 2 into ys. Place 3 into ys. Keep a shared linefirst of 0. Keep a shared linesecond of 0. Keep a shared linecount of 0. Keep a shared best of 0. Keep a shared lastpoint of 0. Set best to 1. Set lastpoint to 2.
To check point at spot (a whole number). The anchor is linefirst. The other is linesecond. The dx is item other of xs minus item anchor of xs. The dy is item other of ys minus item anchor of ys. The otherx is item spot of xs minus item anchor of xs. The othery is item spot of ys minus item anchor of ys. If dx times othery is dy times otherx, add 1 to linecount.

To scan from spot (a whole number). If spot is more than lastpoint, return. If spot is not linefirst and spot is not linesecond, check point at spot. Scan from spot plus 1.

To score from first (a whole number) with second (a whole number). Set linefirst to first. Set linesecond to second. Set linecount to 2. Scan from 0. If linecount is more than best, set best to linecount.

For every first from 0 to lastpoint.
For every second from first plus 1 to lastpoint.
Score from first with second.

Show best.
```

**Expected stdout**

```text
3
```

## #0150 · Evaluate Reverse Polish Notation

**Medium · Array** · [Open in Playground](https://ponvasanthpon.github.io/TransCompilator/#problem=0150) · [Static page](https://ponvasanthpon.github.io/TransCompilator/problems/0150.html)

```text
Keep a shared tokens holding "2", "1", "+", "3", and "*". Keep a shared current as empty text. Keep a shared value of 0.
To read from spot (a whole number) with last (a whole number). If spot is more than last, return. The digit is the digit value of character spot of current. Set value to value times 10 plus digit. Read from spot plus 1 with last.

The stack is an empty list of whole numbers. The depth is 0. The left is 0. The right is 0. The result is 0.
For each token in tokens.
Set current to a copy of token. The sign is 1. The start is 0. If character 0 of current is "-", set sign to -1, set start to 1. Set value to 0. The lastchar is the last position of current. Read from start with lastchar. Set value to value times sign. The symbol is character 0 of current. If symbol is "+", set right to item (depth minus 1) of stack, remove the last item from stack, subtract 1 from depth, set left to item (depth minus 1) of stack, remove the last item from stack, subtract 1 from depth, set result to left plus right, Place result into stack, add 1 to depth. If symbol is "-", set right to item (depth minus 1) of stack, remove the last item from stack, subtract 1 from depth, set left to item (depth minus 1) of stack, remove the last item from stack, subtract 1 from depth, set result to left minus right, Place result into stack, add 1 to depth. If symbol is "*", set right to item (depth minus 1) of stack, remove the last item from stack, subtract 1 from depth, set left to item (depth minus 1) of stack, remove the last item from stack, subtract 1 from depth, set result to left times right, Place result into stack, add 1 to depth. If symbol is "/", set right to item (depth minus 1) of stack, remove the last item from stack, subtract 1 from depth, set left to item (depth minus 1) of stack, remove the last item from stack, subtract 1 from depth, set result to left divided by right, Place result into stack, add 1 to depth. If symbol is between "0" and "9", Place value into stack, add 1 to depth.

Show item 0 of stack.
```

**Expected stdout**

```text
9
```

## #0151 · Reverse Words in a String

**Medium · String** · [Open in Playground](https://ponvasanthpon.github.io/TransCompilator/#problem=0151) · [Static page](https://ponvasanthpon.github.io/TransCompilator/problems/0151.html)

```text
The sentence is "the sky is blue". The parts is split sentence by " ". The words is an empty list of text.
For each part in parts.
If the length of part is more than 0, Place part into words.

The last is the last position of words. The result is empty text.
For every step from 0 to last.
The source is last minus step. If the length of result is more than 0, Place " " into result. Place item source of words into result.

Show result.
```

**Expected stdout**

```text
blue is sky the
```

[Chunk 04 →](chunk-04.md)
