当前位置: 首页 > news >正文

LeetCode知识点总结 - 537

LeetCode 537. Complex Number Multiplication

考点难度
MathMedium
题目

A complex number can be represented as a string on the form “real+imaginaryi” where:

real is the real part and is an integer in the range [-100, 100].
imaginary is the imaginary part and is an integer in the range [-100, 100].
i2 == -1.
Given two complex numbers num1 and num2 as strings, return a string of the complex number that represents their multiplications.

思路

(a + bi) * (c + di) = (ac - bd) + (ad + bc)i

答案
classSolution{publicStringcomplexNumberMultiply(Stringa,Stringb){int[]coefs1=Stream.of(a.split("\\+|i")).mapToInt(Integer::parseInt).toArray(),coefs2=Stream.of(b.split("\\+|i")).mapToInt(Integer::parseInt).toArray();return(coefs1[0]*coefs2[0]-coefs1[1]*coefs2[1])+"+"+(coefs1[0]*coefs2[1]+coefs1[1]*coefs2[0])+"i";}}
http://www.jsqmd.com/news/578755/

相关文章:

  • OpenClaw技能开发入门:为Phi-3-mini-128k-instruct定制自动化插件
  • 稳健的独热编码
  • 2026 年真正必备的 10 个 Claude 插件(以及它们的作用)
  • SwartNinjaPIR:嵌入式高可靠PIR运动检测驱动库
  • 社交媒体应用的安全策略与用户屏蔽机制
  • 嵌入式开发中的模块化编程与驱动分离实践
  • 【OpenClaw 安全部署与使用指南:从零构建可信赖的 AI 助手】
  • 物流园区灵活用电计量物联网解决方案
  • 跨国系统避坑:IANA 时区与夏令时(DST)完美处理方案
  • LSM303DLH六轴传感器原理与嵌入式驱动开发
  • 茶叶工艺能耗监测系统方案
  • 突破音频限制:OpenCore-Legacy-Patcher焕新老Mac音质体验
  • 1.3 多模态工具扩展:让 Agent 拥有“眼睛“与“双手“
  • 基于胸部正位X光片的两阶段对比学习椎体压缩性骨折筛查框架文献速递-多模态医学影像最新进展
  • Linux who命令实现:文件读写与系统编程实践
  • TGP Ecran:Arduino OLED显示库的轻量封装与非阻塞刷新设计
  • ESP32-Arduino IDE的开发学习记录(二)显示屏
  • 为什么你的C++量子模拟器总在2^10后崩溃?内存优化、张量压缩与SIMD加速三重方案揭秘
  • RPlatform教育机器人运动控制库详解
  • 群晖 /dev/md0 根分区爆满 100% 排查清理全流程
  • 拯救996:OpenClaw+百川2-13B量化模型自动生成周报
  • OpenClaw社交媒体管理:Gemma-3-12b-it自动回复评论与生成周报
  • 从一次RDP爆破到全网挖矿:复盘Windows Server 3389端口的安全加固与监控策略
  • DOCX转LaTeX:从繁琐排版到学术自动化的无缝过渡
  • OpenClaw+Qwen3-14b_int4_awq:跨平台文件同步助手
  • 端边云协同,全域智治——奥尔特云智慧安保解决方案
  • 短视频 SEO 优化能给企业带来什么好处_短视频 SEO 如何优化视频标题和描述
  • 6月PMP考试紧急冲刺指南:没好好备考?这样做还能逆风翻盘
  • 头歌实践教学-NLP:基于决策树与正则表达式的词法分析实战
  • OpenClaw跨平台对比:Windows/macOS对接Qwen3-14B差异详解