当前位置:网站首页>[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]边栏推荐
- 自定义注解实现校验
- What if the disk of datanode is full?
- What is the difference between Pipeline and Release Pipeline in azure devops?
- Web compatibility testing of software testing
- Orb-slam2 source code learning (II) map initialization
- History of deep learning
- The quantity and quality of the devil's cold rice 101; Employee management; College entrance examination voluntary filling; Game architecture design
- Installing mongodb database in Windows Environment
- JS方法大全的一个小文档
- 冲击继电器ZC-23/DC220V
猜你喜欢

dc_labs--lab1的学习与总结

Chapter 53 overall understanding of procedures from the perspective of business logic implementation

uniapp官方组件点击item无效,解决方案
![Split the linked list [take next first and then cut the linked list to prevent chain breakage]](/img/eb/708ab20c13df75f4dbd2d6461d3602.png)
Split the linked list [take next first and then cut the linked list to prevent chain breakage]

集群与LVS介绍及原理解析

解决IDEA:Class ‘XXX‘ not found in module ‘XXX‘
![分割链表[先取next再斩断链表防止断链]](/img/eb/708ab20c13df75f4dbd2d6461d3602.png)
分割链表[先取next再斩断链表防止断链]

Sword finger offer 19 Regular Expression Matching

Analyzing the wisdom principle in maker education practice

Implementation of date class
随机推荐
uniapp官方组件点击item无效,解决方案
K210门禁毕设
K210 access control complete
用recyclerReview展示Banner,很简单
Split the linked list [take next first and then cut the linked list to prevent chain breakage]
C语言一点点(未来可会增加)
StrictMode分析Activity泄漏-StrictMode原理(3)
ESP8266 RC522
酒旅板块复苏,亚朵继续上市梦,距离“新住宿经济第一股“还有多远?
[network packet loss and network delay? This artifact can help you deal with everything!]
Tcp/ip protocol stack, about TCP_ RST | TCP_ ACK correct attitude
友盟(软件异常实时监听的好帮手:Crash)接入教程(有点基础的小白最易学的教程)
Principes de formation de la programmation robotique
Analyzing the wisdom principle in maker education practice
Cmu15445 (fall 2019) project 1 - buffer pool details
[learning notes] double + two points
The communication mechanism and extension of Supervisor
Kongyiji's first question: how much do you know about service communication?
Basic knowledge of software and hardware -- diary (1)
解析创客教育实践中的智慧原理