Simple BST with values 1,2,3 — print inorder sum.
Toolliyo Coach
Progressive help: Nudge → Guide → Approach. Full solution stays behind the Solution tab.
Editor is open — no login wall to practice.
| Test | Status | Details |
|---|
Ready — edit the code above and click Run or Submit.
using System;
using System.Collections.Generic;
class Node { public int Val; public Node L, R; public Node(int v) => Val = v; }
class Program {
static void Main() {
var root = new Node(2) { L = new Node(1), R = new Node(3) };
int sum = 0;
void Dfs(Node n) { if (n == null) return; Dfs(n.L); sum += n.Val; Dfs(n.R); }
Dfs(root);
Console.WriteLine(sum);
}
}
Prefer Coach (Nudge → Guide → Approach) before revealing. No forced signup.
Inorder DFS on binary tree.
Sign in to save and review your submission history. You can still Run code on the Editor tab as a guest.
Sign in