diff --git a/guide/portuguese/algorithms/search-algorithms/linear-search/index.md b/guide/portuguese/algorithms/search-algorithms/linear-search/index.md index 24259deeea..5c5ea7263a 100644 --- a/guide/portuguese/algorithms/search-algorithms/linear-search/index.md +++ b/guide/portuguese/algorithms/search-algorithms/linear-search/index.md @@ -97,6 +97,50 @@ def linear_search(array, num): return -1 ``` +### Exemplo em Swift +```swift +func linearSearch(for number: Int, in array: [Int]) -> Int? { + for (index, value) in array.enumerated() { + if value == number { return index } // return the index of the number + } + return nil // the number was not found in the array +} +``` + +### Exemplo em Java +```java +int linearSearch(int[] arr, int element) +{ + for(int i=0;i