列表

详情


JS25. 相同的Set

描述

请补全JavaScript代码,要求以boolean的形式返回两个Set对象参数是否一样,是则返回true,否则返回false。

原站题解

HTML/CSS/JavaScript 解法, 执行用时: 1692ms, 内存消耗: 77772KB, 提交时间: 2022-02-08

{"css":"","js":"","html":"<!DOCTYPE html>\n<html lang=\"en\">\n    <head>\n        <meta charset=\"UTF-8\">\n    </head>\n    <body>\n        \n        <script>\n            const _isSameSet = (s1, s2) => {\n                // 补全代码\n                if (s1.size !== s2.size) return false;\n                return [...s1.values()].every(v => s2.has(v));\n            }\n        </script>\n    </body>\n</html>","libs":[]}

HTML/CSS/JavaScript 解法, 执行用时: 1734ms, 内存消耗: 77772KB, 提交时间: 2021-12-05

{"css":"","js":"","html":"<!DOCTYPE html>\n<html lang=\"en\">\n    <head>\n        <meta charset=\"UTF-8\">\n    </head>\n    <body>\n        \n        <script>\n            const _isSameSet = (s1, s2) => {\n                // 补全代码\n                return s1==s1\n            }\n        </script>\n    </body>\n</html>","libs":[]}

HTML/CSS/JavaScript 解法, 执行用时: 1738ms, 内存消耗: 77772KB, 提交时间: 2021-12-05

{"css":"","js":"","html":"<!DOCTYPE html>\n<html lang=\"en\">\n    <head>\n        <meta charset=\"UTF-8\">\n    </head>\n    <body>\n        \n        <script>\n          const _isSameSet = (s1, s2) => {\n    if (s1.size !== s2.size) {\n        return false\n    }\n    return [...s1].every(i => s2.has(i))\n}\n\n        </script>\n    </body>\n</html>","libs":[]}

HTML/CSS/JavaScript 解法, 执行用时: 1739ms, 内存消耗: 77872KB, 提交时间: 2022-01-22

{"css":"","js":"","html":"<!DOCTYPE html>\n<html lang=\"en\">\n    <head>\n        <meta charset=\"UTF-8\">\n    </head>\n    <body>\n        \n        <script>\n            const _isSameSet = (s1, s2) => {\n                // 补全代码\n                if (s1.size !== s2.size)\n                    return false\n                for (const e of s1) {\n                    if (!s2.has(e))\n                        return false\n                }\n                return true\n            }\n        </script>\n    </body>\n</html>","libs":[]}

HTML/CSS/JavaScript 解法, 执行用时: 1740ms, 内存消耗: 77792KB, 提交时间: 2022-01-22

{"css":"","js":"","html":"<!DOCTYPE html>\n<html lang=\"en\">\n    <head>\n        <meta charset=\"UTF-8\">\n    </head>\n    <body>\n        \n        <script>\n            const _isSameSet = (s1, s2) => {\n                // 补全代码\n                if(JSON.stringify(s1)==JSON.stringify(s2)) return true;\n                return false;\n            }\n        </script>\n    </body>\n</html>","libs":[]}

上一题