0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

LeetCode ::: 268 /// Missing Number

Last updated at Posted at 2019-10-15

:sparkles::tea: 思考回路

合計して相殺する

  • インプットの長さを変数 len に入れて(私が文字数を短くしたいので :relaxed:
  • で、変数 suppose はもし数字が紛失しなかったら、本来あるべき合計値。等差数列の和の公式を使います。ゼロは足す必要がないので項数はちょうど len と等しいです。
  • 今インプットの配列も合計し、変数 sum に入れます。
  • suppose と sum を相殺させて、その結果が紛失した数字です。

See the Pen LeetCode ::: 268 /// Missing Number by jujuriri (@jujuriri) on CodePen.

--- :sob::pray_tone1: 自力で解決法を考え出すことが出来る優しい問題ですね。
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?