From 031c5b679c95a411737ce8cd6e93676d78378ca7 Mon Sep 17 00:00:00 2001 From: Deven <63876261+devenperez@users.noreply.github.com> Date: Mon, 25 Nov 2024 15:44:08 -0500 Subject: [PATCH] Create README - LeetHub --- 2619-array-prototype-last/README.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 2619-array-prototype-last/README.md diff --git a/2619-array-prototype-last/README.md b/2619-array-prototype-last/README.md new file mode 100644 index 0000000..634997f --- /dev/null +++ b/2619-array-prototype-last/README.md @@ -0,0 +1,28 @@ +

2619. Array Prototype Last

Easy


Write code that enhances all arrays such that you can call the array.last() method on any array and it will return the last element. If there are no elements in the array, it should return -1.

+ +

You may assume the array is the output of JSON.parse.

+ +

 

+

Example 1:

+ +
+Input: nums = [null, {}, 3]
+Output: 3
+Explanation: Calling nums.last() should return the last element: 3.
+
+ +

Example 2:

+ +
+Input: nums = []
+Output: -1
+Explanation: Because there are no elements, return -1.
+
+ +

 

+

Constraints:

+ +