@StefanPochmann
Hi Stefan whether it's necessary to use
if(Math.abs(x - arr[mid]) > Math.abs(arr[mid + k] - x))
instead of
if(x - arr[mid] > arr[mid + k] - x)
in your Java Solution. And if not, why. Thanks.
Life Sucks, Suck It Harder
@StefanPochmann
Hi Stefan whether it's necessary to use
if(Math.abs(x - arr[mid]) > Math.abs(arr[mid + k] - x))
instead of
if(x - arr[mid] > arr[mid + k] - x)
in your Java Solution. And if not, why. Thanks.
@kekan No, it should return 32 since Integer.MAX_VALUE = 2^31 - 1
, you should use Integer.MAX_VALUE plus 1 at first and then devide it by 2 for 31 times. So there are 32 operations in total.
@venkateshkumar
For "abcadcbb",isnt the longest substring adcb ,whose length is 4?
Thanks for sharing, I was think whether this problem could be solved with backtracking...
Why should we make sure that s.length() == low.length() or s.length() == high.length() when we decide whether new String is in range?
if ((s.length() == low.length() && s.compareTo(low) < 0) ||
(s.length() == high.length() && s.compareTo(high) > 0)) {
return;
}
Hello all , I am confused by the lines above. Because I think String.compareTo() in java would consider about the length at first and then the unicode order according to Java api. However, after I remove the s.length() == low.length() or s.length() == high.length()
It is wrong, I am really confused about this point. Someone to save me out of it?
@ares_1197 You r right, recently they add some new test case. I have already updated the most recent version of my solution
@StefanPochmann said in Java in-place:
you are as neat as always,but could you please explain the line below a little bit?
M[i][j] += 256 + M[I][J] % 256 * 4096;