Comment

Comment by amirkdv

> > given a list of numbers, return two numbers such that one times the other results in 220

> > is the list sorted?

> this barely qualifies as a clarifying question in my opinion.

Maybe I'm being too charitable but whether or not the list is sorted is very relevant to the first solution that came to my mind as I read the problem.

  for i from 1 to n:
    for j from i+1 to n:
      prod = a[i] * a[j]
      if prod == 220:
        # found it
      if prod > 220:
        break
        # don't waste time, assumes sorted
parent amirkdv 6 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton