题目地址:
https://www.lintcode.com/problem/is-alphanumeric/description
判断一个字符是否是数字或者字母。
代码如下:
public class Solution {
/**
* @param c: A character.
* @return: The character is alphanumeric or not.
*/
public boolean isAlphanumeric(char c) {
// write your code here
return Character.isDigit(c) || Character.isLetter(c);
}
}
时空复杂度 O ( 1 ) O(1) O(1)。