编程语言单选难度 3真题改编 · 2024
284. 实现一个函数,检查一个整数数组是否包含重复元素实现一个函数,检查一个整数数组是否包含重复元素。
#include <stdio.h>
#include <stdbool.h>
bool containsDuplicate(int* nums, int size)
{
for (int i = 0; i < size - 1; i++)
{
for (int j = i + 1; j < size; j++)
{
if (____) // 填空
{
return true;
}
}
}
return false;
}
int main()
{
int nums[] = {1, 2, 3, 4, 5, 3};
int size = sizeof(nums) / sizeof(nums[0]);
printf("%d\n", containsDuplicate(nums, size));
return 0;
}
补充代码为:
练习本题 ›
算法与数据结构哈希单选难度 3真题改编 · 2024
290. 已知一组关键字为{11, 22, 33, 44, 55, 66, 77, 88, 99, 110},采用线性探测法处理冲突,散列表是一个下标从0开始的长度为17的一维数组,散列函数为H(key) = key MOD 17,则关键字55的结点地址是()
练习本题 ›