Skip to content

oybekjohn/Binarysearch-problems

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

12 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Leetcode

Easy

  • 1389 Create Target Array in the Given Order
class Solution:
    def createTargetArray(self, nums: List[int], index: List[int]) -> List[int]:
        new_list = []
        
        for i in range(len(index)):
            new_list.insert(index[i], nums[i])
            
        return new_list

--------------------------------------------------------------------------------------------------------

  • 1 Two Sum
class Solution:
    def twoSum(self, nums: List[int], target: int) -> List[int]:
        
        complement = {}
        for i in range(len(nums)):
            if (target - nums[i]) in complement:
                return [i, complement.get(target - nums[i])]
            else:
                complement[nums[i]] = i

--------------------------------------------------------------------------------------------------------

Medium

Hard