mirror of
https://github.com/krahets/hello-algo.git
synced 2026-08-29 11:27:13 +00:00
zig : upgrade codes && rust : add codes for chapter_searching and chapter_dynamic_programming. (#591)
* zig : update zig codes * rust : add codes for linear_search and hashing_search * rust : add codes for linear_search and hashing_search * rust : add codes for chapter_dynamic_programming
This commit is contained in:
@@ -31,7 +31,7 @@ pub fn main() !void {
|
||||
var map = std.AutoHashMap(i32, i32).init(std.heap.page_allocator);
|
||||
defer map.deinit();
|
||||
for (nums, 0..) |num, i| {
|
||||
try map.put(num, @intCast(i32, i)); // key: 元素,value: 索引
|
||||
try map.put(num, @as(i32, @intCast(i))); // key: 元素,value: 索引
|
||||
}
|
||||
var index = hashingSearchArray(i32, map, target);
|
||||
std.debug.print("目标元素 3 的索引 = {}\n", .{index});
|
||||
|
||||
Reference in New Issue
Block a user