HOLA

6 views
Skip to first unread message

ABHISHEK KALWAR

unread,
Nov 20, 2015, 1:40:53 AM11/20/15
to kubt...@googlegroups.com

    public static int[] getJoinedPipes(int input1,int[] input2) throws Exception
    {
        //Write code here
        int[] output = {0};
        Exception e=new IOException();
        if(input1>1)
        {
            Arrays.sort(input2);
            output = new int[input1-1];
            if(input2[0]<1||input2[2]<1)
                throw e;
            output[0] = input2[0]+input2[1];
            for(int i=2;i<input1;i++)
            {
                output[i-1] = output[i-2]+input2[i];
            }
        }
        return output;
    }
Reply all
Reply to author
Forward
0 new messages