mirror of
https://github.com/krahets/hello-algo.git
synced 2026-04-14 10:20:40 +08:00
add zig codes for Section 'Space Complexity' and 'Space Time Tradeoff'
This commit is contained in:
21
codes/zig/include/TreeNode.zig
Normal file
21
codes/zig/include/TreeNode.zig
Normal file
@@ -0,0 +1,21 @@
|
||||
// File: TreeNode.zig
|
||||
// Created Time: 2023-01-07
|
||||
// Author: sjinzh (sjinzh@gmail.com)
|
||||
|
||||
const std = @import("std");
|
||||
|
||||
// Definition for a binary tree node
|
||||
pub fn TreeNode(comptime T: type) type {
|
||||
return struct {
|
||||
const Self = @This();
|
||||
|
||||
val: T = undefined,
|
||||
left: ?*Self = null,
|
||||
right: ?*Self = null,
|
||||
|
||||
// Initialize a tree node with specific value
|
||||
pub fn init(self: *Self, x: i32) void {
|
||||
self.val = x;
|
||||
}
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user