
Asked in Twitter
Break The Board Problem Statement
Your task is to break a board of given dimensions 'L' by 'W' into 'L' * 'W' smaller squares, ensuring the total cost of breaking is minimized.
Input:
The first line contains an integer 'T' indicating the number of test cases.
For each test case, the input is as follows:
- A line with two space-separated integers, 'L' and 'W', representing the length and width.
- A line with 'L' - 1 integers denoting the cost of each horizontal cut.
- A line with 'W' - 1 integers denoting the cost of each vertical cut.
Output:
For each test case, output an integer representing the minimum cost required to break the board into 'L' * 'W' squares.
Example:
Input:
1
4 3
2 1 3
1 2
Output:
10
Constraints:
1 ≤ T ≤ 10
2 ≤ L, W ≤ 104
1 ≤ costL[i], costW[i] ≤ 105
- Time Limit: 1 second
Note:
You are not required to print anything manually; implement the function to get the expected results.

AnswerBot
4mo
Minimize cost of breaking a board into smaller squares by optimizing horizontal and vertical cuts.
Iterate through all possible horizontal and vertical cuts to find the minimum cost
Use dynamic programm...read more
Help your peers!
Add answer anonymously...
Top Software Developer Interview Questions Asked at Twitter
Q. Explain the process of calling an API.
Q. How do you test the feasibility of an idea?
Q. Fibonacci Number Verification Identify if the provided integer 'N' is a Fibonacc...read more
Interview Questions Asked to Software Developer at Other Companies
Top Skill-Based Questions for Twitter Software Developer
Algorithms Interview Questions and Answers
250 Questions
Data Structures Interview Questions and Answers
250 Questions
Web Development Interview Questions and Answers
250 Questions
Java Interview Questions and Answers
250 Questions
SQL Interview Questions and Answers
250 Questions
Software Development Interview Questions and Answers
250 Questions
Stay ahead in your career. Get AmbitionBox app


Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+
Reviews
10L+
Interviews
4 Cr+
Salaries
1.5 Cr+
Users
Contribute to help millions
AmbitionBox Awards
Get AmbitionBox app

