Solved

parentbit challenge

Posted on 2016-09-21
3
74 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
  • 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
This is about my first experience with programming Arduino.
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

895 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now