Sort by

recency

|

417 Discussions

|

  • + 1 comment

    My C++ solution

    int twoStacks(int maxSum, vector<int> a, vector<int> b) {
        int i = 0, j = 0, sum = 0, count = 0;
    
        while (i < a.size() && sum + a[i] <= maxSum) {
            sum += a[i];
            i++;
        }
        count = i; 
    
    
        while (j < b.size() && i >= 0) {
            sum += b[j];
            j++;
            
            while (sum > maxSum && i > 0) {
                i--;
                sum -= a[i];
            }
    
            if (sum <= maxSum) {
                count = max(count, i + j);
            } else {
                break; 
            }
        }
    
        return count;
    }
    
  • + 0 comments

    Honestly, nothing beats that explosive feeling of hitting a massive multiplier when you've played your cards just right. It’s a rush as wild and unpredictable as a safari through the Maasai Mara, and honestly, using 1Win has been the absolute game-changer for my daily earnings lately. Being a savvy player from Kenya, I’m always on the lookout for platforms that don't mess around with payouts or slow systems. You just have to stay sharp, trust the process, and soon enough, you'll be celebrating a huge victory that changes everything for you.

  • + 0 comments

    While the Game of Two Stacks focuses on mathematical strategy and optimization, sometimes it’s nice to take a break with a more creative and relaxing simulation. If you enjoy the problem-solving aspects of gaming, you should explore avatar world secrets codes, an innovative role-playing game by Pazu Games where you can customize characters and design dream spaces in a vibrant, interactive world. It’s a great way to balance intense logic puzzles with immersive storytelling and fun mini-games.

  • + 0 comments

    Game of Two Stacks” sounds like a fun puzzle-style challenge where you make smart moves to clear the stacks in the best order. If you enjoy simple strategy games, you might also like platforms such as OK Win Game, but always play for fun and keep things light and responsible. Website: https://okwingame.io/

  • + 0 comments
    {
        stack<int> a1;
        stack<int> b1;
        int val = 0;
        int tmp = 0;
        int t = 0;
        for (int i = a.size() - 1; i >= 0; i--)
        {
            a1.push(a[i]);
        }
        for (int i = b.size() - 1; i >= 0; i--)
        {
            b1.push(b[i]);
        }
    
        while (tmp <= maxSum && (!a1.empty() || !b1.empty()))
        {
            val = t;
    
            if (!a1.empty() && (b1.empty() || a1.top() <= b1.top()))
            {
                tmp += a1.top();
                a1.pop();
                t += 1;
            }
            else if (!b1.empty())
            {
                tmp += b1.top();
                b1.pop();
                t += 1;
            }
        }
        return val;
    }
    

    what is the problem