일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
- stock trading
- URI
- The Internet
- Web Crawler
- Daishin Securities
- mime type
- Rest
- Version Control
- Instance
- pyinstaller
- KOSDAQ
- handleMethodsArgumentNotValid
- Creon
- Stock
- automated system
- header
- spec
- WebServer
- RecursionError: maximum recursion depth exceeded while calling a Python object
- mongodb
- python
- Slack
- ExceptionHandler
- creon login
- request param
- API
- AESCipher
- AWS
- Auto Login
- EC2
- Today
- Total
Change the Better World
Leetcode - Two Sum 본문
Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target.
You may assume that each input would have exactly one solution, and you may not use the same element twice.
You can return the answer in any order.
class Solution(object):
def twoSum(self, nums, target):
"""
:type nums: List[int]
:type target: int
:rtype: List[int]
"""
t = target
l = []
for i in range(len(nums)):
for j in range(i+1, len(nums)):
t -= nums[i]
if t == nums[j]:
l.append(i)
l.append(j)
return l
else:
t = target
'Programming > Python' 카테고리의 다른 글
Valid Parentheses (0) | 2022.06.11 |
---|---|
Longest Common Prefix (0) | 2022.06.09 |
Roman to Integer (0) | 2022.06.07 |
Leetcode - Palindrome Number (0) | 2022.06.04 |
pyinstaller.exe 실행시, "RecursionError: maximum recursion depth exceeded while calling a Python object" 발생 (0) | 2021.03.14 |