Skip to content

Commit 9f0c3be

Browse files
committed
Add solution #2619
1 parent 4814ac9 commit 9f0c3be

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,7 @@
362362
2529|[Maximum Count of Positive Integer and Negative Integer](./2529-maximum-count-of-positive-integer-and-negative-integer.js)|Easy|
363363
2535|[Difference Between Element Sum and Digit Sum of an Array](./2535-difference-between-element-sum-and-digit-sum-of-an-array.js)|Easy|
364364
2618|[Check if Object Instance of Class](./2618-check-if-object-instance-of-class.js)|Medium|
365+
2619|[Array Prototype Last](./2619-array-prototype-last.js)|Easy|
365366
3392|[Count Subarrays of Length Three With a Condition](./3392-count-subarrays-of-length-three-with-a-condition.js)|Easy|
366367
3396|[Minimum Number of Operations to Make Elements in Array Distinct](./3396-minimum-number-of-operations-to-make-elements-in-array-distinct.js)|Easy|
367368
3397|[Maximum Number of Distinct Elements After Operations](./3397-maximum-number-of-distinct-elements-after-operations.js)|Medium|
+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/**
2+
* 2619. Array Prototype Last
3+
* https://leetcode.com/problems/array-prototype-last/
4+
* Difficulty: Easy
5+
*
6+
* Write code that enhances all arrays such that you can call the array.last() method on
7+
* any array and it will return the last element. If there are no elements in the array,
8+
* it should return -1.
9+
*
10+
* You may assume the array is the output of JSON.parse.
11+
*/
12+
13+
/**
14+
* @return {null|boolean|number|string|Array|Object}
15+
*/
16+
Array.prototype.last = function() {
17+
return !this.length ? -1 : this[this.length - 1];
18+
};

0 commit comments

Comments
 (0)