Hi
Please explain the question
Question Unclear Doubt
hello @vatsal50
about input data->
You are given an array of integers. Here the sign of the integer represents the direction of the arrow, ‘+’ : right and ‘-’ : left. The absolute value represents the size of the arrow.
when collision will happen ->
A collisions will take place if an arrow is moving towards right and the next arrow moves in the left direction. At each collision the arrow with larger size destroys the smaller sized arrow and continues the path(. If both the arrows have same size then they both are destroyed.
what u have to print->
in the end u need to print the final state ie u need to print arrows that are not destroyed with their respective directions
In which statement u are having issue?
can u explain with the help of example?
5
1 -1 2 -5 7
all positive arrows are moving right, and all negative arrows are moving left.
so they will collide and arrow with higher magnitude destroy arrow with less magnitude.
1 -1 will destroy each other(becuase they have same magnitude).
-5 will destroy 2 (5 has higher magnitude than 2)
-5 and 7 will never collide becuase -5 is moving in left and 7 is moving in right and 5 is in left of 7 .
so final answer will be
-5 7
Can we code in java and will our doubt be answered if we code in java?
…
depends on TA whether he/she is proficient in that particular language or not.
but they all can help u with the logic of the problem
in the example given in question, how 3rd -5 is destroyed by 7?
…
no -5 (3rd one) cannot be destoyed by 7 becuase they are moving away from each other.
it is the last -5 that is destroyed by 7
yes. the last one . How it is destroyed by 7?
1 -1 2 -5 7 -6 -5 3 -5 10
7 is moving to right. it will destroy all the arrows which are having lesser magnitude and moving towards left.
here (-6 , -5(2nd one) , -5(3rd one) ) ) moving towards left and are having magnitude less than 7 , so they will get destroyed by 7
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.