Skip to content

Commit c8d68bf

Browse files
committed
ADDED TWO ARRAY PROGRAM
1 parent a4dd7c3 commit c8d68bf

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

Data-Structures/Array/leadersinarray.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* [Leaders in an Array](https://www.geeksforgeeks.org/dsa/leaders-in-an-array/)
2+
* [Leaders in an Array](https://www.geeksforgeeks.org/leaders-in-an-array/)
33
*
44
* A leader in an array is an element that is greater than or equal to
55
* all the elements to its right.
@@ -45,4 +45,4 @@ function leaders(arr) {
4545
// Driver code
4646
const arr = [16, 17, 4, 3, 5, 2];
4747
const result = leaders(arr);
48-
console.log(result.join(" "));
48+
console.log(result.join(' '));

Data-Structures/Array/test/checkarraysortedornot.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
*/
2121

2222
function isSorted(arr) {
23-
let n = arr.length;
23+
const n = arr.length;
2424

2525
// Iterate over the array and check if
2626
// every element is greater than or equal to previous element.
@@ -34,11 +34,10 @@ function isSorted(arr) {
3434
}
3535

3636
// Driver Code
37-
let arr = [10, 20, 30, 40, 50];
38-
let n = arr.length;
37+
const arr = [10, 20, 30, 40, 50];
3938

4039
if (isSorted(arr)) {
41-
console.log("true");
40+
console.log('true');
4241
} else {
43-
console.log("false");
42+
console.log('false');
4443
}

0 commit comments

Comments
 (0)