mirror of
https://github.com/krahets/hello-algo.git
synced 2026-04-13 18:00:18 +08:00
update zig codes for Section 'Space Complexity' and 'Space Time Tradeoff'
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user