Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
1.7 kB
1
Indexable
Never
1. 

class Solution {
    List<int> a=[];
    int indecator=-1;
 List<int> twoSum(List<int> numbers, int target) {
     for(int i =0;i<numbers.length;i++){
         for(int j=i+1;j<numbers.length;j++){
             if(numbers[i]+numbers[j]==target){indecator++;
a.add(i);a.add(j);
             }
         }
     }
     return a;
 }
}


4. 

class Solution {
  double findMedianSortedArrays(List<int> nums1, List<int> nums2) {
double check=0;int div=0;double result = 0;
      for(int i = 0;i<nums2.length;i++){
          nums1.add(nums2[i]);
      }
  nums1.sort();
    print(nums1);
    check = nums1.length%2;
      check = check/2;div=(nums1.length/2).round()-1;
    print(check);   
    print(div); 
    print(nums1.length/2);
   

    
    if(check!=0){result = nums1[div]/1;}else{
      result = (nums1[div]+nums1[div+1])/2;
    }
 
    return result;
  }
}


7. 

class Solution {
    int rev=0;

  int reverse(int x) {
int temp=x;
    while (x != 0) {
        if(x<0){
            x=x*-1;
             rev = rev * 10 + x % 10;
        x = x ~/ 10;
        
        }
        if(x>0){
        rev = rev * 10 + x % 10;
        x = x ~/ 10;}
    }
    if(temp<0){
        rev=rev*-1;
    }
    return rev <= pow(-2, 31) || rev >= (pow(2, 31) - 1)
    ? 0
    : rev;
  }
}


9. 


class Solution {

int sum=0;num ? temp;int ?reminder;

  bool isPalindrome(int x) {
temp=x;
  while(x>0)
  {
    reminder = x % 10;
    sum = (sum*10)+reminder!;
    x = x~/10;
  }
return sum==temp? true:false;

  }
}

33.

class Solution {
  int search(List<int> nums, int target) {
  int res=0;
  if(nums.contains(target)){
    res=nums.indexOf(target);
    
  }else{res=-1;}
print(res)
; return res; }

}