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
• 361

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).

OR
OR
Register

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

• Hire
• Post Projects

### Post Projects

• All at 0 Cost ....
• Post Tech Job
• Select Best Bidder
• Track the Project
• Approve Work and Pay safely
• Browse Nerds
• Work
• Find Projects Find Projects
• UI Design and UX
• Software Engineering
View more...
View less...
• Marketing
• General
View more...
View less...
• Manage
• Company Company

### Manage Company

• All at 0 Cost ....
• Manage Company and Employee Profiles
• Company wide Employee Productivity Reports
• Knowledge Sharing and Collaboration Tools
• Get Sales Lead and Bid for Tech Projects
• Send Invoices and Receive Payment Safely
• Learn
• Nerd Digest Nerd Digest
• UI Design and UX
• Software Engineering
View more...
View less...
• Marketing
• General
View more...
View less...
• Tech Q & A Tech Q & A
• UI Design and UX
• Software Engineering
View more...
View less...
• Marketing
• General
View more...
View less...