Solved

parentbit challenge

Posted on 2016-09-21
3
125 Views
Last Modified: 2016-09-22
Hi,

I am going through below challenge

Recursion-1 > parenBit
prev  |  next  |  chance
Given a string that contains a single pair of parenthesis, compute recursively a new string made of only of the parenthesis and their contents, so "xyz(abc)123" yields "(abc)".

parenBit("xyz(abc)123") → "(abc)"
parenBit("x(hello)") → "(hello)"
parenBit("(xy)1") → "(xy)"
i have not understood the description. please advise
0
Comment
Question by:gudii9
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 37

Expert Comment

by:zzynx
ID: 41810242
>> i have not understood the description.
What don't you understand?

Given a string containing '(' and ')', you have to strip off everything before the '(' and after the ')'.
0
 
LVL 37

Accepted Solution

by:
zzynx earned 500 total points
ID: 41810256
Consider this:
public String parenBit(String str) {
  if (str.startsWith("(")) {
     return "(" + str.substring(1, str.indexOf(")")+1);
  }
  return parenBit(str.substring(1));
}

Open in new window

0
 
LVL 7

Author Comment

by:gudii9
ID: 41810896
i missed the link

http://codingbat.com/prob/p137918


i understood the chalenge now
0

Featured Post

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question