LeetCode——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.

原题链接:https://oj.leetcode.com/problems/valid-number/

推断字符串是否是数字。

规则:出现+, - 则必须是第一个。或前一个是e;有. 则是小数,之前不可有.e;有e。则前面要有.,不能有e,而且后面要有.

可用正則表達式来解答。

	public static boolean isNumber(String s) {
		String reg = "[+-]?(\\d+\\.?|\\.\\d+)\\d*(e[+-]?\\d+)?

"; return s.trim().matches(reg); }






  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
插件名字叫leetcode editor,可以解决在上班时想刷leetcode但又不想直接打开leetcode界面太扎眼或者无法debug的问题。你可以在IDEA的plugins中搜索并下载leetcode editor插件。 插件的下载地址是https://plugins.jetbrains.com/plugin/12132-leetcode-editor。 下载并安装插件后,你可以在IDEA的File -> Settings -> Tools -> Leetcode Plugin***com作为网址选项。此外,你还可以选择代码类型,包括Java、Python、C、Python3、C、C#、JavaScript、Ruby、Swift、Go、Scala、Kotlin、Rust、PHP。你需要输入登录名和密码来登录leetcode账号,并可以设置临时文件的存放目录和HTTP Proxy。 如果你想自定义代码模板,可以参考该插件提供的自定义代码模板文档(https://github.com/shuzijun/leetcode-editor/blob/master/doc/CustomCode.md)。通过这个插件,你可以方便地在IDEA中刷leetcode,并享受更好的调试体验。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [好用的idea插件leetcode editor【详细安装指南】](https://blog.csdn.net/weixin_45988401/article/details/129170239)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *2* *3* [IDEA插件系列(112):LeetCode Editor插件——LeetCode编辑器](https://blog.csdn.net/cnds123321/article/details/119859448)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值