golodnov.kirill
BAN USERBFS should work fine here, where each element of matrix (filled with 1) is a vertex of graph and two vertices are connected if they are neighbors.
- golodnov.kirill August 02, 2014If you start building binary heap from original array, there can be a situation described below by vgeek - when value in left branch of second level is lower than some value in the right branch of third level. This will cause not a minimal weight of a tree.
- golodnov.kirill August 07, 2013You should add all elements of array to HashMap. When you add number e, find if number (n - e) already presents in HashMap. But be careful with value n/2, if n is even.
- golodnov.kirill August 04, 2013Hi,
I think, this will produce incorrect result for array {3, 2, 1}. You will have F = {3, 2, 1}, G = {3, 2, 1}, won't you? And the wise-difference will be 0. But the answer seems to be -1.
By the way, your algorithm is incorrect only for strictly decreasing arrays.
Repcoragkemmer, Data Scientist at Bankbazaar
Have years of experience to treating variety of outpatients with modalities such as massage, exercise, paraffin, joint mobilization, mechanical traction ...
You need to go through the given string and keep the counter:
- golodnov.kirill January 09, 20181. If you see '(' then you should increment the counter.
2. If you see ')' then you should decrement the counter. If the counter is negative then return false.
At the end of the given string the counter should be zero.