LeetCode 2441. Largest Positive Integer That Exists With Its Negative — JavaScript

Gary Huang
Traveling Light Taipei
May 8, 2024
Apple announces new iPad Pros with OLED displays and thinnest design ever

https://leetcode.com/problems/largest-positive-integer-that-exists-with-its-negative/description/?envType=daily-question&envId=2024-05-02

HI~你領500元現金了嗎? 點選我的連結成功開樂天帳戶+登入樂天網銀APP,拿500元現金! 樂天帳戶好康在這 : · 使用行動支付5次,享次月活儲年息1.35%存額無上限 · VIP享每月免費跨提/轉共16次 · 提領日幣手續費優惠8次/月 (推薦序號: JGONGL)
https://www.rakuten-bank.com.tw/s/R775

var findMaxK = function(nums) {
const set = new Set(nums)
let max = -1
nums.forEach(e=>{
if(set.has(e*-1)) max = Math.max(max,e)
})
return max
};

找到最大數字於nums中有對應負數

日本越後湯澤滑雪 石打丸 Gala 輕井澤 Tani Yuuki 菅原圭 — Cheers / FunkyGary / Japan — Echigo-Yuzawa

--

--

Gary Huang
Traveling Light Taipei

自學程式,目前爲 React 前端工程師,兼職線上課程業師,協助程式自學者就業。熱愛旅遊,將近 30 個國家。訂閱我的旅行與街舞 YT :https://www.youtube.com/channel/UCEU-bEDl7R-iGyLVZFae33g