65-Valid Number
Description
Validate if a given string is numeric.
Some examples:
"0" => true
" 0.1 " => true
"abc" => false
"1 a" => false
"2e10" => true
Note: It is intended for the problem statement to be ambiguous. You should gather all requirements up front before implementing one.
問題描述
驗證給定字串是否為有效的數
問題分析
面試的時候注意與面試官溝通細節。。。
解法
class Solution {
public boolean isNumber(String s) {
return s.matches("^\\s*[-+]?((\\d+(\\.\\d*)?)|(\\.\\d+))(e[-+]?\\d+)?\\s*$");
}
}
相關文章
- JavaScript Number()JavaScript
- JavaScript Number 物件JavaScript物件
- Leetcode Number of islandsLeetCode
- Kata:Hamming number
- JavaScript Number toLocaleString()JavaScript
- JavaScript Number toString()JavaScript
- Number.NaNNaN
- Serial number lookup for Panasonic
- D. The Number of Imposters
- Big Number hd 1212
- 7.104 ITERATION_NUMBER
- Leetcode 447 Number of BoomerangsLeetCodeOOM
- react input[type='number']React
- number(p,s)(轉)
- Last digit of a huge numberASTGit
- [HNU 10072] Fibonacci Number
- Python Number(數字)Python
- Perfect Number 完美數
- [LeetCode] Third Maximum NumberLeetCode
- [LeetCode] Find the Duplicate NumberLeetCode
- Leetcode 9 Palindrome NumberLeetCode
- 136. Single Number
- Number.parseInt() 方法
- Number.parseFloat()方法
- Number.isSafeInteger()方法
- Number.isNaN()方法NaN
- Number.isFinite()方法
- Js中的NumberJS
- Number.POSITIVE_INFINITY
- Number.ATIVE_INFINITY
- Python convert string to unicode numberPythonUnicode
- Number of k-good subarraysGo
- D. Soldier and Number GameGAM
- Bad magic number for central directory
- 7.34 BITMAP_BUCKET_NUMBER
- number----char(to_char)
- HDU 1711 Number Sequence(KMP)KMP
- Java Number和Math 類Java