Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8698879
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T01:49:11+00:00 2026-06-13T01:49:11+00:00

Given a string consisting of number, add + or – sign to make the

  • 0

Given a string consisting of number, add + or – sign to make the expression values 0. Return the expression.

For example,

123 => 1 + 2 -3 = 0

173956 => 17 + 39 – 56 = 0

I have no clues to solve this problem other than a brute-force way.

Is there any suggestion?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T01:49:12+00:00Added an answer on June 13, 2026 at 1:49 am

    This is a search problem. Search must be performed in the solution space.
    Suppose we starting from ‘123’ string, at this point, we can add + or – sign after ‘1’, as result we get ‘1 + 23’ or ‘1 – 23’. Every variant can be split further by adding a sign after next character. As result, all possible sign additions will form tree-like structure – the solution space. Your algorithm must search solution in this structure. I think A* can be used to do this.

    Anders K draw nice ASCII graph of the solution space, you just need to search it for solution. Simple breadth first search or depth first search can do the work, but I think it will be slow if solution space is large.

    Also, I think that is possible to find more optimal, specific solution that exploits properties of the solution space, for example – it’s tree-like structure.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given a string consisting of a single character followed by a number (one or
I have used the crypt function in c to encrypt the given string. I
what would be the regular expression to check if a given string contains atleast
What regular expression can I use (if any) to validate that a given string
This is an interview problem that I am stuck on: Given a string consisting
I have a pattern @@{} and given a string I need to find out
This is an interview question. Given a string such as: 123456abcdef consisting of n/2
I am trying to generate a unique string/id given another relatively large string(consisting of
I have a very simple table(mapped as AuthToken class), consisting of a string ('token'),
I am solving this problem- Given a string consisting of a,b and c's, we

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.