leetcode/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;
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
leetcode/lc/2822/
多种编程语言实现 LeetCode、《剑指 Offer(第 2 版)》、《程序员面试金典(第 6 版)》题解
https://doocs.github.io/leetcode/lc/2822/
Beta Was this translation helpful? Give feedback.
All reactions