mirror of
https://github.com/TheAlgorithms/JavaScript.git
synced 2026-02-04 05:06:59 +08:00
merge: FindSecondLargestElement: Support negative numbers (#1036)
* FindSecondLargestElement: Support negative numbers
* Updated Documentation in README.md
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
This commit is contained in:
@@ -11,7 +11,7 @@
|
||||
|
||||
const secondLargestElement = (array) => {
|
||||
const largestElement = Math.max(...array)
|
||||
let element = 0
|
||||
let element = -Number.MAX_VALUE
|
||||
|
||||
for (let i = 0; i < array.length; i++) {
|
||||
if (element < array[i] && array[i] !== largestElement) {
|
||||
|
||||
Reference in New Issue
Block a user