Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 25th, 2012  |  syntax: None  |  size: 0.76 KB  |  hits: 18  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Java confusion on fundamentals on double and integer and conversions
  2. public double findMedianSortedArrays(int A[], int B[])
  3.        
  4. Input       Output  Expected    
  5. [], [1]      1.0    1    
  6. [2], []      2.0    2
  7.        
  8. if(array.length %2 == 0){
  9.  
  10.      return (array[middle] + array[middle - 1])/(double)2;    
  11.  }
  12.  else{
  13.       return (double)array[middle];
  14.  
  15.   }
  16.        
  17. public class Solution {
  18.     public double findMedianSortedArrays(int A[], int B[]) {
  19.         // Start typing your Java solution below
  20.         // DO NOT write main() function
  21.         return 0;
  22.     }
  23. }
  24.        
  25. class Solution {
  26. public:
  27.     double findMedianSortedArrays(int A[], int m, int B[], int n) {
  28.         // Start typing your C/C++ solution below
  29.         // DO NOT write int main() function
  30.         return 0;
  31.     }
  32. };