fork download
  1. class Solution {
  2. public int searchInsert(int[] nums, int target) {
  3. int n =nums.length;
  4.  
  5. int low=0;
  6. int high=n-1;
  7.  
  8. int res=0;
  9. if(target >nums[n-1]){
  10. return n;
  11. }
  12. while(low<=high){
  13. int mid=low+(high-low)/2;
  14. if(nums[mid] < target){
  15. low=mid+1;
  16. }
  17. else if(nums[mid] >= target){
  18. res=mid;
  19. high=mid-1;
  20. }
  21. }
  22. return res;
  23. }
  24. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
spoj: The program compiled successfully, but main class was not found.
      Main class should contain method: public static void main (String[] args).
stdout
Standard output is empty