博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
leetCode 65.Valid Number (有效数字)
阅读量:4627 次
发布时间:2019-06-09

本文共 1350 字,大约阅读时间需要 4 分钟。

Valid Number 
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.
Update (2015-02-10):

The signature of the C++ function had been updated. If you still see your function signature accepts a const char * argument, please click the reload button  to reset your code definition.

思路:此题是真的有些难度的,并且最重要的是我根本就不清楚一个有效数字的规则。。

一个连规则都不知道的人怎么能玩好游戏呢,所以果断的挂了10次8次的。最后还是没有全然答对。

临时把别人的代码拿出来放在以下。有时间再好好研究一下:

public class Solution {    public boolean isNumber(String s) {        // Start typing your Java solution below        // DO NOT write main() function       /*               "0" => true        "     0.1     " => true        "abc" => false        "1 a" => false        "+-2e10" => true        //*/        //check input.        if(s==null || s.length()==0) return false;        int sz = s.length();        int i=0;                while(i
='0' && c<='9') { number = true; } else if((c=='+' || c=='-') && neg==false && number==false ) { neg = true; } else { return false; } } return number; }}

转载于:https://www.cnblogs.com/cxchanpin/p/7207099.html

你可能感兴趣的文章
Geohash距离估算
查看>>
Demon_背包系统(实现装备栏,背包栏,可以切换装备)
查看>>
记录:一次数据库被恶意修改配置文件的问题
查看>>
redis 持久化
查看>>
解决Jupyter notebook[import tensorflow as tf]报错
查看>>
Windows平台下使用ffmpeg和segmenter实现m3u8直播点播
查看>>
python网络画图——networkX
查看>>
ubuntu16.04文件形式安装mongodb
查看>>
SpringBoot------ActiveMQ安装
查看>>
详细了解 int? 类型
查看>>
字符串匹配 ?kmp : hash
查看>>
mongod.service: control process exited, code=exited status=1
查看>>
c# 发送邮件、附件 分类: C# 2014-12-...
查看>>
对360来说,江湖上再无“搜狗”这个传说
查看>>
composer
查看>>
OpenCV特征点检测——ORB特征
查看>>
mysql的csv数据导入与导出
查看>>
leetcode笔记:Pascal&#39;s Triangle
查看>>
ASP.NET性能优化之构建自定义文件缓存
查看>>
Shell——windows上写完放入linux的时候需要注意的问题
查看>>