mirror of
https://github.com/krahets/hello-algo.git
synced 2026-08-19 06:50:59 +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:
@@ -11,7 +11,7 @@ fn linearSearchArray(comptime T: type, nums: std.ArrayList(T), target: T) T {
|
||||
for (nums.items, 0..) |num, i| {
|
||||
// 找到目标元素, 返回其索引
|
||||
if (num == target) {
|
||||
return @intCast(T, i);
|
||||
return @intCast(i);
|
||||
}
|
||||
}
|
||||
// 未找到目标元素,返回 -1
|
||||
|
||||
Reference in New Issue
Block a user