55 lines
1.0 KiB
Python
55 lines
1.0 KiB
Python
from string import *
|
|
from re import *
|
|
from datetime import *
|
|
from collections import *
|
|
from heapq import *
|
|
from bisect import *
|
|
from copy import *
|
|
from math import *
|
|
from random import *
|
|
from statistics import *
|
|
from itertools import *
|
|
from functools import *
|
|
from operator import *
|
|
from io import *
|
|
from sys import *
|
|
from json import *
|
|
from builtins import *
|
|
import string
|
|
import re
|
|
import datetime
|
|
import collections
|
|
import heapq
|
|
import bisect
|
|
import copy
|
|
import math
|
|
import random
|
|
import statistics
|
|
import itertools
|
|
import functools
|
|
import operator
|
|
import io
|
|
import sys
|
|
import json
|
|
from typing import *
|
|
|
|
# @leet start
|
|
class Solution:
|
|
def twoSum(self, numbers: List[int], target: int) -> List[int]:
|
|
i = 0
|
|
j = len(numbers) - 1
|
|
while i < j:
|
|
need = target - numbers[i]
|
|
if need == numbers[j]:
|
|
break
|
|
if need < numbers[j]:
|
|
j -= 1
|
|
elif need > numbers[i]:
|
|
i += 1
|
|
|
|
return [i + 1, j + 1]
|
|
|
|
|
|
|
|
# @leet end
|