Source Code: Solution - 1: Using two for loop
- check with every number with other number if multiplication of two number matches to given value
Time Complexity: O(n^2)
Space Complexity: O(1)
Solution - 2: Using Sorting
- Sort the array
- Now take two pointer from start & end
- If multiplication of start & end index value is greater than given value decrease the end index by 1
- If multiplication of start & end index value is less than given value increase the start index by 1
- If multiplication of start & end index value is equal to given value return true
Time Complexity: O(nlogn)
Space Complexity: O(1)
Solution - 3: Using HashSet
- We initialize hashset
- Traverse array & if val/a[i] doesn't exist in hashset, insert a[i] value in hashset
- if val/a[i] exists in hashset then there exists a pair
Time Complexity: O(n)
Space Complexity: O(n)
Do Watch video for more info
CHECK OUT CODING SIMPLIFIED
★☆★ VIEW THE BLOG POST: ★☆★
I started my YouTube channel, Coding Simplified, during Dec of 2015.
Since then, I've published over 400+ videos.
★☆★ SUBSCRIBE TO ME ON YOUTUBE: ★☆★
★☆★ Send us mail at: ★☆★
Email: thecodingsimplified@gmail.com

0 Comments