码迷,mamicode.com
首页 > 其他好文 > 详细

[LeetCode] Expression Add Operators 表达式增加操作符

时间:2015-09-16 21:59:22      阅读:478      评论:0      收藏:0      [点我收藏+]

标签:

 

Given a string that contains only digits 0-9 and a target value, return all possibilities to add operators +-, or * between the digits so they evaluate to the target value.

Examples: 

"123", 6 -> ["1+2+3", "1*2*3"] 
"232", 8 -> ["2*3+2", "2+3*2"]
"00", 0 -> ["0+0", "0-0", "0*0"]
"3456237490", 9191 -> []

Credits:
Special thanks to @davidtan1890 for adding this problem and creating all test cases.

[LeetCode] Expression Add Operators 表达式增加操作符

标签:

原文地址:http://www.cnblogs.com/grandyang/p/4814506.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!