Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

lc/2822/ #3637

giscus[bot] bot announced in Announcements
Oct 13, 2024 · 1 comment
Discussion options

lc/2822/

多种编程语言实现 LeetCode、《剑指 Offer(第 2 版)》、《程序员面试金典(第 6 版)》题解

https://leetcode.doocs.org/lc/2822/

You must be logged in to vote

Replies: 1 comment

Comment options

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;
}
You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant

AltStyle によって変換されたページ (->オリジナル) /