Location: Menlo Park, California
Question asked:
Variation of expression add opertaors without * operator
Confused it with https://leetcode.com/problems/target-sum/
at first but interviewer pointed in the right direction.
Example 1:
Input: num = "123", target = 6
Output: ["1+2+3"]
Example 2:
Input: num = "105", target = 5
Output: ["10-5"]
https://leetcode.com/problems/expression-add-operators/
Provided Java Backtrace accepted Solution .
Interviewer asked about additional cases where the expression can start with + or - (Input: num = "510", target = 5
Output: ["-5+10"]) and if the input String has trailing spaces. I(nput: num = " 123", target = 6
Output: ["1+2+3"] )
Answered by starting substring from 0th position and using String.trim() on input string to get rid of trailing spaces in input string.