Sort by

recency

|

251 Discussions

|

  • + 0 comments

    Shadow Fight 2 is a popular action-packed fighting game that blends classic martial arts combat with RPG elements. Players control a shadowy warrior on a quest to defeat powerful enemies and close the Gates of Shadows. With smooth animations, realistic fighting mechanics, and a variety of weapons and skills to master, the game offers an engaging experience. Shadow Fight 2 stunning visuals, challenging battles, and character upgrades keep players hooked, making it one of the most iconic mobile fighting games.

  • + 0 comments
    /*
     * Complete the 'gameOfStones' function below.
     *
     * The function is expected to return a STRING.
     * The function accepts INTEGER n as parameter.
     */
    
    
    string gameOfStones(int n) {
        vector<int> t = {1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0};
        int k = t.size();
        if (n <= 10) {
            return (t[n] == 0) ? "First" : "Second";
        }
        t.resize(n+1);
        for (int j = k; j <= n; ++j) {
            if ((t[j - 2] == 0) && (t[j - 3] == 0) && (t[j - 5] == 0)) {
                t[j] = 1;
            }
        }
        return (t[n] == 0) ? "First" : "Second";
    }
    
  • + 0 comments

    Here is my Python solution!

    def gameOfStones(n):
        if n % 7 == 0 or n % 7 == 1:
            return "Second"
        return "First"
    
  • + 0 comments

    My Java solution with linear time and space complexity

    public static String gameOfStones(int n) {
            // goal: print the name of the winner
            if(n == 1) return "Second";
            
            boolean[] moves = new boolean[n + 1];
            
            moves[0] = false;
            for(int i = 1; i <= n; i++){
                boolean canWin = false;
                
                if (i >= 2 && !moves[i - 2]) canWin = true;
                if (i >= 3 && !moves[i - 3]) canWin = true;
                if (i >= 5 && !moves[i - 5]) canWin = true;
    
                moves[i] = canWin;
            }
            
            return moves[n] ? "First" : "Second";
        }
    
  • + 0 comments

    try to think with 7 divisible value(hint)