This year’s Google I/O 2021 is going to be held virtually. To reveal the event’s date Google has come up with an intriguing Punch Card Puzzle 🧩 for the developers. I would suggest you try it on your own first and if you stuck somewhere you can refer to this article.

Puzzle 1: Find the Quote

You have to find the person who said the following quote.

You can copy and paste the quote on Google to find the person.

“It matters little who first arrives at an idea, rather what is significant is how far that idea can go.”
- Sophie Germain.

As you…

Given an array of integers nums and an integer targetSum, return two numbers such that they add up to targetSum

Input: nums = [2,7,11,15], targetSum = 18

Output: [7,11]

Method 1: Using Two For Loops

This is a naive approach in which we will be using two nested loops and checking if at any point they are equal to ourtargetSum.

def twoNumberSum(nums, targetSum):
for i in range(len(nums)-1):
for j in range(i+1,len(nums)):
if targetSum == nums[i]+nums[j]:
return [nums[i],nums[j]]
return []

For every element in the given array nums we will check with other elements present whether the sum of both of the element equals to our targetSum…

Ayush Yadav

Coder ⚡ Developer ⚡Writer

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store