update zig codes for Section 'Space Complexity' and 'Space Time Tradeoff'

This commit is contained in:
sjinzh
2023-01-10 17:19:21 +08:00
parent 2d461b03a4
commit 2572b83540
8 changed files with 23 additions and 4 deletions

View File

@@ -5,6 +5,7 @@
const std = @import("std");
// Definition for a singly-linked list node
// 编译期泛型
pub fn ListNode(comptime T: type) type {
return struct {
const Self = @This();

View File

@@ -7,6 +7,7 @@ const ListNode = @import("ListNode.zig").ListNode;
const TreeNode = @import("TreeNode.zig").TreeNode;
// Print an array
// 编译期泛型
pub fn printArray(comptime T: type, nums: []T) void {
std.debug.print("[", .{});
if (nums.len > 0) {

View File

@@ -5,6 +5,7 @@
const std = @import("std");
// Definition for a binary tree node
// 编译期泛型
pub fn TreeNode(comptime T: type) type {
return struct {
const Self = @This();