I have a map like this as shown below...
Key Value
23 20
32 20 (20+20 =40 , min=23 max=32)
43 18
45 24 (24+18 =42 , since 42 >40 so here min and max will be same that is 43
47 10
56 6 (24 +10 +6 =40) so here min =45 and max = 56
49 2
47 12
so as shown above there will be final constant named split whose value is 40
final int SPLIT = 40; //this will be configurable as it value can be changed.
so I have to implmenet the logic such as that if the value of the map reaches to 40 then first key of the map from where the calculation started and he key where exactly it reaches to 40wilkl be choosen as min and max also explained above
besides this care need to be taken the\at if sum reaches more than 40 then we have to ignore it and taking the previous value itself as min amd max in tha case min and max will be equal.
Please advise how to achieve the same through java in map