Skip to content

Commit 797f387

Browse files
committedJan 23, 2025
Add solution #2727
1 parent c634fe7 commit 797f387

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed
 

‎README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,7 @@
487487
2722|[Join Two Arrays by ID](./2722-join-two-arrays-by-id.js)|Medium|
488488
2723|[Add Two Promises](./2723-add-two-promises.js)|Easy|
489489
2724|[Sort By](./2724-sort-by.js)|Easy|
490+
2727|[Is Object Empty](./2727-is-object-empty.js)|Easy|
490491
3042|[Count Prefix and Suffix Pairs I](./3042-count-prefix-and-suffix-pairs-i.js)|Easy|
491492
3110|[Score of a String](./3110-score-of-a-string.js)|Easy|
492493
3223|[Minimum Length of String After Operations](./3223-minimum-length-of-string-after-operations.js)|Medium|

‎solutions/2727-is-object-empty.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/**
2+
* 2727. Is Object Empty
3+
* https://leetcode.com/problems/is-object-empty/
4+
* Difficulty: Easy
5+
*
6+
* Given an object or an array, return if it is empty.
7+
*
8+
* - An empty object contains no key-value pairs.
9+
* - An empty array contains no elements.
10+
*
11+
* You may assume the object or array is the output of JSON.parse.
12+
*/
13+
14+
/**
15+
* @param {Object|Array} obj
16+
* @return {boolean}
17+
*/
18+
var isEmpty = function(obj) {
19+
return !Object.keys(obj).length;
20+
};

0 commit comments

Comments
 (0)
Please sign in to comment.