Sort by

recency

|

40 Discussions

|

  • + 0 comments

    In Kotlin, I got an overflow error in some test cases. I needed to change the return type for Long to make it pass.

  • + 0 comments
    #include <iostream>
    using namespace std;
    void rectangularGame(int n)
    {
        unsigned long long int a,b, minA, minB;
        for(int i=0; i<n; i++)
        {
            cin>>a>>b;
            if(i==0)
            {
                minA=a;
                minB=b;
            }
            if(a<minA)
            {
                minA=a;
            }
            if(b<minB)
            {
                minB=b;
            }
        }
        cout<<minA*minB;
    }
    int main()
    {
        int n;
        cin>>n;
        rectangularGame(n);
        return 0;
    }
    
  • + 0 comments

    Java :

    import java.util.Scanner;
    
    public class Solution {
        public static void main(String[] args) {
            Scanner sc = new Scanner(System.in);
            int n = sc.nextInt();
            int a = Integer.MAX_VALUE, b = Integer.MAX_VALUE;
            while (n-- > 0) {
                a = Math.min(a, sc.nextInt());
                b = Math.min(b, sc.nextInt());
            }
            
            System.out.println(1L * a * b);
        }
    }
    
  • + 0 comments

    python code def solve(steps): x = [] y = [] for i in range(n): x.append(steps[i][0]) y.append(steps[i][1]) x1 = min(x) y1 = min(y) result = x1*y1 return result

  • + 0 comments

    My Python code, which passed all the test cases:

    def solve(steps):
        steps_tr = list(zip(*steps))  #list 'steps' transposed
        return min(steps_tr[0])*min(steps_tr[1])