Mister-Hope
Mister-HopeC++JavaJavaScriptPHPPython3TypeScript
C++
/**
* Your runtime beats 100 % of cpp submissions
* Your memory usage beats 100 % of cpp submissions (6 MB)
*/
class Solution {
public:
bool canWinNim(int n) { return n % 4 != 0; }
};
Java
/*
* Your runtime beats 100 % of java submissions
*
* Your memory usage beats 10.33 % of java submissions (35.4 MB)
*/
class Solution {
public boolean canWinNim(int n) {
return n % 4 != 0;
}
}
JavaScript
/*
* Your runtime beats 60.95 % of javascript submissions
*
* Your memory usage beats 24.26 % of javascript submissions (38.4 MB)
*/
const canWinNim = (n) => n % 4 !== 0;
simple
/*
* Your runtime beats 60.95 % of javascript submissions
*
* Your memory usage beats 24.26 % of javascript submissions (38.4 MB)
*/
const canWinNim = (n) => Boolean(n % 4);
PHP
/**
* Your runtime beats 80 % of php submissions
*
* Your memory usage beats 100 % of php submissions (15.6 MB)
*/
class Solution {
/**
* @param Integer $n
* @return Boolean
*/
function canWinNim($n) {
return $n $ 4;
}
}
Python3
# Your runtime beats 90.8 % of python3 submissions
#
# Your memory usage beats 100 % of python3 submissions(14.2 MB)
class Solution:
def canWinNim(self, n: int) -> bool:
return n % 4 != 0
TypeScript
/*
* Your runtime beats 100 % of typescript submissions
*
* Your memory usage beats 88.89 % of typescript submissions (38.8 MB)
*/
const canWinNim = (n: number): boolean => n % 4 !== 0;
simple
/*
* Your runtime beats 100 % of typescript submissions
*
* Your memory usage beats 88.89 % of typescript submissions (38.8 MB)
*/
const canWinNim = (n: number): boolean => Boolean(n % 4);