I just went through link given by Milind and there the question is same but the value in arr in {1,2,3,4}. If I solve it on paper it gives me the answer 0030 which is the correct answer. But if I try to code it and solve it on my laptop, it gives the answer 0000. Where am I going wrong? Or the JVM is wrong?? Please help.