-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
83526e3
commit 13896b9
Showing
1 changed file
with
19 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity >=0.5.0 <0.9.0; | ||
|
||
contract Day5 { | ||
//Create a function search(array, length of array,element to search) . This search() will take three arguments - a dynamic uint type array ,length of the array, element that we need to search. | ||
|
||
function search( | ||
int256[] memory arr, | ||
uint256 size, | ||
int256 toSearch | ||
) public pure returns (uint256) { | ||
for (uint256 i = 0; i < size; i++) { | ||
if (arr[i] == toSearch) { | ||
return 1; //if element is found | ||
} | ||
} | ||
return 0; //if element is not found | ||
} | ||
} |