add zig codes for Section 'Hash Map' and 'Linear Search'
This commit is contained in:
parent
722fb71bdd
commit
6f65c84e36
@ -47,7 +47,8 @@ pub fn main() !void {
|
||||
const mem_allocator = mem_arena.allocator();
|
||||
var head = try inc.ListUtil.listToLinkedList(i32, mem_allocator, nums);
|
||||
var node = linearSearchLinkedList(i32, head, target);
|
||||
std.debug.print("目标结点值 3 的对应结点对象为 {any}", .{node});
|
||||
std.debug.print("目标结点值 3 的对应结点对象为 ", .{});
|
||||
try inc.PrintUtil.printLinkedList(i32, node);
|
||||
|
||||
const getchar = try std.io.getStdIn().reader().readByte();
|
||||
_ = getchar;
|
||||
|
@ -16,6 +16,7 @@ pub fn ListNode(comptime T: type) type {
|
||||
// Initialize a list node with specific value
|
||||
pub fn init(self: *Self, x: i32) void {
|
||||
self.val = x;
|
||||
self.next = null;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -17,6 +17,8 @@ pub fn TreeNode(comptime T: type) type {
|
||||
// Initialize a tree node with specific value
|
||||
pub fn init(self: *Self, x: i32) void {
|
||||
self.val = x;
|
||||
self.left = null;
|
||||
self.right = null;
|
||||
}
|
||||
};
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user