cjql / algorithm

https://cjql.github.io/algorithm/
1 stars 1 forks source link

LeetCode #1

Open cjql opened 4 years ago

cjql commented 4 years ago

C++

class Solution {
public:
    bool divisorGame(int N) {
        return N%2 == 0;
    }
};

Java

class Solution {
    public boolean divisorGame(int N) {
        return N%2 == 0;
    }
}

Python

class Solution:
    def divisorGame(self, N: int) -> bool:
        return N%2 == 0

C

bool divisorGame(int N){
    return N%2 == 0;
}

C

public class Solution {
    public bool DivisorGame(int N) {
     return N%2 == 0;   
    }
}

JavaScript

/**
 * @param {number} N
 * @return {boolean}
 */
var divisorGame = function(N) {
    return N%2 == 0
};

Ruby

# @param {Integer} n
# @return {Boolean}
def divisor_game(n)
    return n%2 == 0
end

Swift

class Solution {
    func divisorGame(_ N: Int) -> Bool {
        return N%2 == 0
    }
}

Go

func divisorGame(N int) bool {
    return N%2 == 0
}

Scala

object Solution {
    def divisorGame(N: Int): Boolean = {
     return N%2 == 0   
    }
}

Kotlin

class Solution {
    fun divisorGame(N: Int): Boolean {
        return N%2 == 0
    }
}

Rust

impl Solution {
    pub fn divisor_game(n: i32) -> bool {
        return n%2 == 0
    }
}

PHP

class Solution {

    /**
     * @param Integer $N
     * @return Boolean
     */
    function divisorGame($N) {
        return $N%2 === 0;
    }
}