leetcode 241. Different Ways to Add Parentheses
2017-08-29 11:34
309 查看
class Solution(object): def diffWaysToCompute(self, input): """ :type input: str :rtype: List[int] """ """ https://discuss.leetcode.com/topic/19894/1-11-lines-python-9-lines-c """ return [a+b if c =='+' else a-b if c=='-' else a*b for i,c in enumerate(input) if c in ('+','-','*') for a in self.diffWaysToCompute(input[:i]) for b in self.diffWaysToCompute(input[i+1:])] or [int(input)]
相关文章推荐
- leetcode 241. Different Ways to Add Parentheses (Python版)
- 题解——Leetcode 241. Different Ways to Add Parentheses 难度:Medium
- LeetCode 241. Different Ways to Add Parentheses
- leetcode_middle_34_241. Different Ways to Add Parentheses
- Leetcode——241. Different Ways to Add Parentheses
- Leetcode 241. Different Ways to Add Parentheses
- LeetCode 241. Different Ways to Add Parentheses
- leetcode 241. Different Ways to Add Parentheses
- leetcode题解c++ | 241. Different Ways to Add Parentheses
- [LeetCode] 241. Different Ways to Add Parentheses
- [leetcode] 241. Different Ways to Add Parentheses
- Leetcode:241. Different Ways to Add Parentheses
- LeetCode241. Different Ways to Add Parentheses
- [LeetCode] 241. Different Ways to Add Parentheses 添加括号的不同方式
- 241. Different Ways to Add Parentheses LeetCode
- leetcode 241. Different Ways to Add Parentheses
- 【Leetcode】241. Different Ways to Add Parentheses
- 【LeetCode】241. Different Ways to Add Parentheses
- <LeetCode OJ> 241. Different Ways to Add Parentheses
- LeetCode 241. Different Ways to Add Parentheses