917. Reverse Only Letters

917. Reverse Only Letters

class Solution {
    public String reverseOnlyLetters(String s) {
        char[] arr = s.toCharArray();
            int arrIndex = getNextEmpty(arr.length,arr);

        for(int i = 0 ; i < s.length(); i++){
                char c = s.charAt(i);
                if((c>='a' && c <='z') ||
                    (c>='A' && c <='Z')){
                    arr[arrIndex] = c;
                    arrIndex = getNextEmpty(arrIndex,arr);
                    }
        }
        return new String(arr);
    }
    public int getNextEmpty(int current, char[] arr){
        for(int i = current-1; i >=0; i--){
            char c = arr[i];
            if((c >='a' && c <='z') ||
                    (c>='A' && c <='Z')) return i;
        }
        return 0;
    }
}

1603. Design Parking System

1603. Design Parking System

class ParkingSystem {
 static int big = 0;
 static int medium = 0;
 static int small = 0;
    public ParkingSystem(int big1, int medium1, int small1) {
        big = big1;
        medium = medium1;
        small = small1;
    }
    
    public boolean addCar(int carType) {
        if(carType == 1){
            if(big >= 1){
                big--;
                return true;
            }else return false;
        }else if(carType == 2){
            if(medium >= 1){
                medium--;
                return true;
            } else return false;
        }else if (carType == 3){
            if(small >= 1){
                small--;
                return true;
            }else return false;
        }
        return false;
    }
}

/**
 * Your ParkingSystem object will be instantiated and called as such:
 * ParkingSystem obj = new ParkingSystem(big, medium, small);
 * boolean param_1 = obj.addCar(carType);
 */

مراجعة القرآن فى يوم الهمة

يشهد مجمع التبيان التعليمى بجامع أم هذلول بأن الطالب

عمر خميس جمال الدين

قد أتم المراجعة من سورة الفاتحة وحتى سورة الأحزاب

وذلك خلال حضوره ليوم الهمة

المقام يوم السبت الموافق 14/6/1444

سائلين المولى عز وجل له التوفيق فى حفظ كتابه

1491. Average Salary Excluding the Minimum and Maximum Salary

1491. Average Salary Excluding the Minimum and Maximum Salary

class Solution {
    public double average(int[] salary) {
        int min = Integer.MAX_VALUE;
        int max = Integer.MIN_VALUE;
        double sum = 0;
        for(int i = 0; i < salary.length; i++){
                sum+=salary[i];
                min = Integer.min(min,salary[i]);
                max = Integer.max(max, salary[i]);
        }
        return (sum-min-max)/(salary.length - 2);
    }
}