title: find pairs of numbers where cube is equal to square
body: <p>We are given a number N and we have to find pairs i and j where i^3=j^2</p>
  <p>For example, let N=50 so for this we will have 3 pairs (1,1),(4,8),(9,27)
  basically, we have to find pairs where the cube of one number is the same as the square of the other number in a given pair</p>
  <p>the constraint is</p>
  <ul>
  <li>1&lt;=N&lt;10^6</li>
  <li>1&lt;=i,j&lt;N</li>
  </ul>
  <p>Naive approach use 2 for loops iterate through each element and get those pairs where cube is equal to sum time complexity is O(n*2)</p>
  <pre><code>def get_pair(N):
      for i in range(1,N):
          for j in range(1,N):
              if i*i*i==j*j:
                  print(i,j)
  N=50
  get_pair(N)
  </code></pre>
  <p>what will be an optimal way to solve this problem with a better time complexity?</p>