I have this function to check if an array has duplicates:
function hasDuplicates(uint256[] memory _array) internal pure returns (bool) {
mapping(uint256 => bool) seen;
for (uint256 i = 0; i < _array.length; i++) {
if (seen[_array[i]]) {
return true;
} else {
seen[_array[i]] = true;
}
}
return false;
}
but I get Data location must be "storage", "memory" or "calldata" for variable, but none was given.
when I try to define mapping(uint256 => bool) seen;