Conversation
Combination Sum (CombinationSum.swift)Your solutions are correct and well-implemented. Here are some points to consider:
VERDICT: PASS Operations and expressions (ExpressionAddOperators.swift)Your solution shows a good understanding of the problem and you've implemented two versions: one with immutable paths and one with backtracking. However, there is a critical error in handling numbers with leading zeros. You should break out of the loop when you encounter a number that starts with '0' and has more than one digit (i.e., when Also, consider using a larger integer type if necessary, but since Swift Int is 64-bit, it should be safe for the constraints. Your backtracking solution (addOperatorsB) is more efficient because it mutates the path in place. However, you need to fix the leading zero issue there as well. Another note: in the first solution, you are passing You might also want to consider using a string builder pattern or an array of characters that you mutate and then convert to a string only when you add to the result. This can reduce memory overhead. Overall, your approach is correct except for the leading zero handling. Fix that and your solution should work. VERDICT: NEEDS_IMPROVEMENT |
Expression Add Operators(https://leetcode.com/problems/expression-add-operators/)
Combination Sum (https://leetcode.com/problems/combination-sum/)