Sort by

recency

|

3057 Discussions

|

  • + 0 comments

    Locksmith Course Liverpool offers hands-on training for those ready to unlock a new career path. This practical course equips you with essential skills in a growing industry. Whether you’re comparing career options like apple and orange, this course stands out with real-world experience and expert guidance. Start your journey with confidence and gain the tools to succeed as a professional locksmith in no time. Enrol today and secure your future.

  • + 0 comments

    c++14

    void countApplesAndOranges(int s, int t, int a, int b, vector<int> apples, vector<int> oranges) {
        size_t val_apple=0;
        size_t val_orange=0;
        for (const auto& x: apples) {
            if((x + a) >= s and (x + a) <= t){
                val_apple++;            
            }
        }
        for (const auto& x : oranges) {
            if( (x + b) <= t and (x + b) >= s){
                val_orange++;            
            }
        }
        cout<<val_apple<<'\n';
        cout<<val_orange<<'\n';
    }
    
  • + 0 comments
        public static void countApplesAndOranges(int s, int t, int a, int b, List<Integer> apples, List<Integer> oranges) {
            
            List <Integer>orangesAfter = new ArrayList<>();
            List <Integer>applesAfter = new ArrayList<>();
            int amountApple=0;
            int amountOrange=0;
            
            for (Integer integer : apples) {
                applesAfter.add(a+integer);
            }
            
            for (Integer integer : oranges) {
                orangesAfter.add(b+integer);
            }
            
            for (Integer integer : applesAfter) {
                if (integer >= s && integer <= t){
                    amountApple++;
                }
            }
            for (Integer integer : orangesAfter) {
                if (integer >= s && integer <= t){
                    amountOrange++;
                }
            }
            
            
            System.out.println(amountApple);
            System.out.println(amountOrange);
        }
    
  • + 0 comments

    one line python ;

    def countApplesAndOranges(s, t, a, b, apples, oranges):
        print(len([i for i in apples if (i + a) <= t and (i + a) >= s]),len([i for i in oranges if (i + b) <= t and (i+b) >= s]), sep = '\n')
    
  • + 0 comments

    In C# 100%

    public static void countApplesAndOranges(int s, int t, int a, int b, List<int> apples, List<int> oranges)
        {
            int appleCount = 0;
            foreach (int distance in apples)
            {
                int landingPosition = a + distance;
                if (landingPosition >= s && landingPosition <= t)
                {
                    appleCount++;
                }
            }
            
            int orangeCount = 0;
            foreach (int distance in oranges)
            {
                int landingPosition = b + distance;
                if (landingPosition >= s && landingPosition <= t)
                {
                    orangeCount++;
                }
            }
    
            Console.WriteLine(appleCount);
            Console.WriteLine(orangeCount);
        }
    }