lc/2822/ #3637
lc/2822/
#3637
Replies: 1 comment
function solve(obj) {
let temp = { ...obj };
const res = {};
Object.entries(temp).forEach(([key, val]) => {
if (res[val] === undefined) res[val] = key;
else if (Array.isArray(res[val])) res[val].push(key);
else res[val] = [res[val], key];
});
return res;
} |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
lc/2822/
多种编程语言实现 LeetCode、《剑指 Offer(第 2 版)》、《程序员面试金典(第 6 版)》题解
https://leetcode.doocs.org/lc/2822/
All reactions