Open mr-mods-yg opened 1 year ago
Suppose we have an array : int[] nums = {3,3,6,6,7,8,8,9}; ---------------s----m------e According to previous code, it will return index 3, but it is wrong in this case. ans should be index 2 as this is first smallest element greator than or equal to target. I can fix this code if u assign me to fix it.
what is target here?
Suppose we have an array : int[] nums = {3,3,6,6,7,8,8,9}; ---------------s----m------e According to previous code, it will return index 3, but it is wrong in this case. ans should be index 2 as this is first smallest element greator than or equal to target. I can fix this code if u assign me to fix it.
what is target here?
target is 6 , I forget to write it there 📟
How does it matter whether we are getting index 2 or 3?
How does it matter whether we are getting index 2 or 3?
It is a sorted array, the ceiling number is the least int number greater than or equal to the given number. so the least int number greater than or equal to is ofcourse 6 but in sorted array if u check from left to right as going in sorted way .The ceiling num is at index 2.
How does it matter whether we are getting index 2 or 3?
It is a sorted array, the ceiling number is the least int number greater than or equal to the given number. so the least int number greater than or equal to is ofcourse 6 but in sorted array if u check from left to right as going in sorted way .The ceiling num is at index 2.
ok ,thanks
Suppose we have an array : int[] nums = {3,3,6,6,7,8,8,9}; and the target is 6 ---------------s----m------e According to previous code, it will return index 3, but it is wrong in this case. ans should be index 2 as this is first smallest element greator than or equal to target. I can fix this code if u assign me to fix it.