LeetCode 1 Two Sum

问题描述

Given an array of integers, find two numbers such that they add up to a specific target number.

The function twoSum should return indices of the two numbers such that they add up to the target, where index1 must be less than index2. Please note that your returned answers (both index1 and index2) are not zero-based.

You may assume that each input would have exactly one solution.

Input: numbers={2, 7, 11, 15}, target=9
Output: index1=1, index2=2

第一篇博客破蛋

为什么要写博客?

  其实一直以来都挺想要有一个属于自己的博客,用来记录那些学习、生活相关的内容。世界那么大,有很多我都想要看,想要做,用博客来提醒自己做一个远离拖延症,想做就去做的人(然而,我估计这个有点不切实际了(⊙﹏⊙)b)。
  其次,看到EclipseFlower的博客,感觉很赞,又听到Carol经常和我提起谁谁谁的博客怎么怎么样,于是心痒痒了,自己也想要来折腾一下,事实证明这真的是一次折腾,折腾了好久才搞定。不过,搞定了之后还是觉得相当开心的,做人嘛,就是要开心~