Skip to content

Instantly share code, notes, and snippets.

@Classy-Bear
Created May 26, 2024 15:35
Show Gist options
  • Save Classy-Bear/5ab6837c9debd7b9243db7e4f648f90b to your computer and use it in GitHub Desktop.
Save Classy-Bear/5ab6837c9debd7b9243db7e4f648f90b to your computer and use it in GitHub Desktop.
void main() {
var list = List.generate(1000, (x) => x + 1);
var result = linearSearch(list, 257);
print('The result is: $result');
}
int? linearSearch(List<int> list, int target) {
for (var i = 0; i < list.length; i++) {
if(list[i] == target) {
return i;
}
}
return null;
}
@Classy-Bear
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment