Sort by

recency

|

3269 Discussions

|

  • + 0 comments

    My Sol for C#

    public static void plusMinus(List arr) { int len = arr.Count; int positiveCount =0; int negativeCount=0; int zeroCount=0;

        foreach(var i in arr)
        {
            if(i>0){
                positiveCount++;
            }
            else if(i<0){
                negativeCount++;
            }
            else if(i==0){
                zeroCount++;
            }
        }
    
        Console.WriteLine(calcRatio(positiveCount,len).ToString("F6"));
        Console.WriteLine(calcRatio(negativeCount,len).ToString("F6"));
        Console.WriteLine(calcRatio(zeroCount,len).ToString("F6"));
    }
    

    public static double calcRatio(int integerCount,int lenArr){

        double ratio = (double) integerCount/lenArr;
        return ratio;
    }
    
        double ratio = (double) integerCount/lenArr;
        return ratio;
    }
    
  • + 0 comments

    Night Latches plus minus these locks are a popular choice for home security, offering quick locking and easy access from inside. They provide convenience and added protection, especially for front doors. However, they can be vulnerable if not paired with a deadlock, and accidental lockouts may occur. Understanding the advantages and disadvantages helps homeowners choose the right security solution for safety, convenience, and everyday peace of mind.

  • + 0 comments

    Locksmith York plus minus situations arise when balancing security upgrades with budget considerations. Professional locksmiths help you choose the right locks, ensuring safety without overspending. From quick lock repairs to full replacements, their expertise supports both residential and commercial needs. Understanding the advantages and limitations of different security options allows you to make informed decisions, keeping your property protected while maintaining cost efficiency and long term reliability.

  • + 0 comments

    My Swift solution

    func plusMinus(arr: [Int]) -> Void {
        let arrCount = Double(arr.count)
        let positiveArrayRatio = Double(arr.count(where: { $0 > 0})) / arrCount
        let negativeArrayRatio = Double(arr.count(where: { $0 < 0})) / arrCount
        let zeroArrayRatio = Double(arr.count(where: { $0 == 0})) / arrCount
    
        print(String(format: "%.6f", positiveArrayRatio))
        print(String(format: "%.6f", negativeArrayRatio))
        print(String(format: "%.6f", zeroArrayRatio))
    } 
    
  • + 0 comments
    function plusMinus(arr) {
        let [pos, neg, zero] = [0, 0, 0];
        for (let i=0; i<arr.length; i++) {
            if (arr[i] === 0) {
                zero += 1;
            } else if (arr[i] < 0) {
                neg += 1;
            } else {
                pos += 1;
            }
        } 
        let len = arr.length;
        console.log((pos / len).toFixed(6));
        console.log((neg / len).toFixed(6));
        console.log((zero / len).toFixed(6));
    }