当前位置:网站首页>[leetcode] sum of two numbers [1]
[leetcode] sum of two numbers [1]
2022-07-01 01:20:00 【When Camellia blossoms.】
problem : Given an array of integers nums And an integer target value target, Please find the sum in the array as the target value target The two integers of , And return their array subscripts ( Be careful : The same element in the array cannot be repeated in the answer )
Example 1
Input : nums = [2,7,11,15], target = 9
Output : [0,1]
explain : because nums[0] + nums[1] == 9, return [0, 1]
Example 2
Input : nums = [3,2,4], target = 6
Output : [1,2]
Example 3
Input : nums = [3,3], target = 6
Output : [0,1]
python3 Problem solving
def twoSum(nums, target):
for i in range(len(nums)):
for j in range(i+1,len(nums)):
if nums[i] + nums[j] == target:
return [i, j]
twoSum([2,7,11,15],9) # [0, 1]
twoSum([3,2,4],6) # [1, 2]
twoSum([3,3],6) # [0, 1]边栏推荐
- 染色法判断二分图
- HDU 2488 A Knight's Journey(DFS)
- StrictMode分析Registion-StrictMode原理(4)
- Web compatibility testing of software testing
- 二十多年来第一次!CVPR最佳学生论文授予中国高校学生!
- [Deepin] 常用集合
- [daily record] - bug encountered in BigDecimal division operation
- [network packet loss and network delay? This artifact can help you deal with everything!]
- None of the following candidates is applicable because of a receiver type mismatch
- Metauniverse and virtual reality (II)
猜你喜欢

High quality pump SolidWorks model material recommended, not to be missed

双位置继电器ST2-2L/AC220V

解读创客教育所蕴含的科技素养

K210 site helmet

For the first time in more than 20 years! CVPR best student thesis awarded to Chinese college students!

Get to know the drawing component of flutter - custompaint

Two position relay st2-2l/ac220v

双位置继电器DLS-5/2 DC220V

人穷志不短,穷学生也能玩转树莓派

XJY-220/43AC220V静态信号继电器
随机推荐
Openmv and k210 of the f question of the 2021 video game call the openmv API for line patrol, which is completely open source.
关于VCTK数据集
[learning notes] structure
软件开发完整流程
Analyzing the wisdom principle in maker education practice
关于Unity一般的输入操作方式
Service
友盟(软件异常实时监听的好帮手:Crash)接入教程(有点基础的小白最易学的教程)
[Deepin] 常用集合
酒旅板块复苏,亚朵继续上市梦,距离“新住宿经济第一股“还有多远?
染色法判断二分图
Analysis of blocktoken principle
K210门禁毕设
Exploring the road of steam education innovation in the Internet Era
Some views on libco
(learning power + thinking power) x action power, summary of flywheel effect on the growth of technicians
pull_ to_ refresh
Sword finger offer 19 Regular Expression Matching
Practical shell knowledge
Koa koa-combine-routers 分路由管理