Essential cookies keep authentication working. With your permission, we also use analytics cookies to understand and improve the product. Read our Privacy Policy

DataEngPrep.tech
QuestionsPracticeAI CoachDashboardPricingBlog
ProLogin
Home/Questions/Python/Coding/Find the three numbers from a list whose multiplication equals 180

Find the three numbers from a list whose multiplication equals 180

Python/Codingeasy2 min read

Reviewed by Aditya Kumar · Last reviewed 2026-03-24

To find three numbers from a list whose product is 180, the most efficient approach involves a combination of mathematical insight and algorithmic optimization. Mechanics and Why The brute force…

🤖 Analyze Your Answer
Frequency
Low
Asked at 1 company
Category
179
questions in Python/Coding
Difficulty Split
127E|24M|28H
in this category
Total Bank
1,863
across 7 categories

Why This Question Matters

This easy-level Python/Coding question appears frequently in data engineering interviews at companies like JIO. While less common, it tests deeper understanding that distinguishes strong candidates.

How to Approach This

Start by clearly defining the core concept being asked about. Interviewers want to see that you understand the fundamentals before diving into implementation details. Structure your answer with a definition, then explain the practical application with a concise example. The expert answer includes a code example that demonstrates the implementation pattern.

Expert Answer
417 wordsIncludes code

To find three numbers from a list whose product is 180, the most efficient approach involves a combination of mathematical insight and algorithmic optimization.

Mechanics and Why

The brute-force solution uses three nested loops, checking every triplet, resulting in an O(N³) time complexity. This is highly inefficient for large lists.

A key optimization stems from the target number's factorization: 180 = 2² × 3² × 5. This means any three numbers multiplying to 180 must be composed solely of these prime factors. This allows for significant pre-filtering of the input list, a common data engineering pattern for reducing data volume before expensive computations.

The problem is a variant of the 3SUM problem. If we fix one number a from the list, we then need to find two other numbers b and c such that b * c = 180 / a. This subproblem can be solved efficiently:

* Hashing (O(N) space, O(N) average time for subproblem): Iterate through the remaining numbers. For each b, calculate target_val = 180 / b. Check if target_val exists in a hash set of previously seen numbers. This leads to an overall O(N²) average time complexity.
* Sorting + Two Pointers (O(1) space, O(N) for subproblem after sort): Sort the remaining numbers. Use two pointers, one starting from the beginning and one from the end, to find b and c that multiply to 180 / a. This approach yields an overall O(N² log N) or O(N²) complexity (if sorting is done once initially).

# Python: Optimized search for b*c = target_val
def find_two_product(nums, target_val):
    seen = set()
    for num in nums:
        if num == 0: continue # Handle zero appropriately
        if target_val % num == 0:
            complement = target_val // num
            if complement in seen:
                return True # Found b, c
            seen.add(num)
    return False

Trade-offs and Production Considerations

In a production data engineering context, the initial factorization and pre-filtering are paramount. For example, in a Spark job, you would filter a DataFrame to include only numbers that are factors of 180 (or whose prime factors are subsets of 180's prime factors) before applying the O(N²) algorithm. This significantly reduces the data processed by the more computationally intensive part. Hashing offers faster average-case lookups but consumes more memory (O(N) space) compared to the O(1) space of the two-pointer approach (after initial sorting).

In the interview, also mention handling edge cases like zeros (avoid division by zero), negative numbers (product could still be 180), and duplicates in the input list.

⚡
Pro Tip

Pro-Move: Factorize + combinatorics. Red Flag: Brute for large lists.

Want all answers as a PDF for offline study?
Seven focused volumes with 750+ in-depth answers — Answer Vault →

Related Python/Coding Questions

easyWhat are traits in Scala, and how are they different from classes?FreemediumWrite a Python function to check if a string is a palindrome.FreeeasyWhat is the difference between a list and a tuple in Python?FreeeasyExplain the difference between shallow copy and deep copy in Python.FreeeasyWrite a Python function to find the first non-repeating character in a string.Free

Level up your prep

Recommended
Educative
Educative Unlimited

800+ hands-on courses — Grokking System Design, Coding Patterns, and AI mock interviews for your DE loop.

Start learning →

Some links below are affiliate links. If you buy through them we may earn a small commission at no extra cost to you — it helps keep DataEngPrep free.

According to DataEngPrep.tech, this is one of the most frequently asked Python/Coding interview questions, reported at 1 company. DataEngPrep.tech maintains an editor-reviewed database of 1,863 data engineering interview questions across 7 categories.

← Back to all questionsMore Python/Coding questions →
Categories
All QuestionsSQLSpark / Big DataPython / CodingSystem DesignCloud / ToolsBehavioral
By Company
AmazonGoogleDatabricksSnowflakeAWSAzureMicrosoftNetflixUberTCS
Interview Guides
All GuidesTop SQL QuestionsTop Spark QuestionsPySpark QuestionsTop Python QuestionsTop System DesignKafka QuestionsAirflow QuestionsSQL Window FunctionsETL QuestionsData Modeling
Products
AI Interview CoachAnswer AnalyzerSQL PlaygroundResume AnalyzerAnswer Vault PDFsPricing
Company
About & Editorial PolicyContact UsAI DisclosureDisclaimerTerms of ServicePrivacy Policy
© 2026 DataEngPrep.tech. All rights reserved.
AboutBlogContactDisclaimer