Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to Solve Array Problem in Java?

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 562
    Answer it

    Monk was surprised to see a new game called, "Conversion Game". In this game, two arrays of N integers A1,A2...AN and B1,B2...BN are playing against each other and Array A wants to convert itself in Array B.

    Array A can do two types of operations on itslef: 
    1 Take two adjacent elements Ai and Ai+1 , increase Ai by 1 and decrease Ai+1 by 1.
    2 Take two adjacent elements Ai and Ai+1 , decrease Ai by 1 and increase Ai+1 by 1.

    Monk being an awesome coder, wants to know whether Array AA can convert itself into Array B, by using any number of such operations. You have to print "YES" (without quotes), if Array AA can convert itself into array B, else print "NO" (without quotes).

    INPUT:
    First line of input will consists of integer T denoting total number of test cases. Each test case will begin with integer N. Next line will consists of N integers A1,A2...AN. Next line will consists of N integers B1,B2...BN.

    OUTPUT:
    Print "YES" (without quotes), if Array A can convert itself into array B by using any number of operations, else print "NO" (without quotes).

 0 Answer(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: