Python : Sum of any two numbers gives target

Опубликовано: 04 Ноябрь 2024
на канале: Grow with Data
178
11

Video 15: This video shows how to loop in a function and search for two numbers whose sum is equal to the target. Initial version of the code shows, how to find the numbers by looping thru the list and take it as first number. The difference between the target and that number, if exist in the rest of the list then append both the numbers to a variable. The key part is the "in" clause for the search
We also discussed, instead of number, how to get the index position of those numbers. For that, we use the index() function and find the position. Finally, we modified the code and make it as a single line of code

code: https://github.com/jeganpillai/python...

Follow me on,
YouTube :    / @growwithdata  
Website : https://growwithdata.co/
LinkedIn :   / growwithdata  
Facebook :   / growwithdata.co  
twitter :   / growwithdata_co  
WhatsApp : https://whatsapp.com/channel/0029VaF8...
Instagram :   / growwithdata.co  


#list #substring #uniquesubset #uniquesubstring #longestsubstring #slicing #lineartimecomplexity #python #pythonquestions #pythontest #pythonprogramming #pythontutorial #python3 #pythonforbeginners #interviewquestions #interview #dataengineers #deinterview #pythoninterview #interviewquestions #leetcode #placementpreparation #meta #google #facebook #apple #netflix #amazon #google #faang #maanga #dataengineers #alphanumeric #nonalphanumeric #growwithdata