• #### Cynthia

i have tried to compile this on my dev C++ and it works ..

• #### Kevin Guevara

Why r.binarySearch?

• #### David

When clicking on the Raw I/O option under Input I see "8":

Input

8 <<<<No Square
25
81
225
841
1024
7056
36
144

Correct Output
5
9
15
29
32
84
6
12

• #### Learneroo

@David, the first number in raw input states how many cases there will be, it's not one of the actual cases.

• #### David

Awesome site this is!

• #### armands

how do i know what is desired number? Should I make anarray from 0 to a, than start at midle checking if that number to power 2is a?

• #### Learneroo

@armands, you don't actually need an array, but that's the right idea (see the hint).

• #### taha

Hi guys, i have written this code https://ideone.com/eFWUiZ its kind of bad, i know it , i suck at recursion but it was a bit logical for me i really don't know where i'm missing up

• #### Learneroo

See if you can keep it organized. If you don't have the right number, see if it's larger or smaller and call your recursive method accordingly. You don't want to have two methods calling each other since that's just confusing. Look over the provided code for binary search and see how to adjust it for the "square root search" problem.

• #### catypus

WOOOHOOO! Man I'm pleased with my implementation of binary search.

However, you see how I got the range for iMid and iMax?

I made a crude estimation there... that the square root of any number could certainly be within the range = a/2

• #### Learneroo

After solving the question here, you can click on the "Featured Answers" link (next to the hint button) to see a possible solution. The idea is to use the same technique as binary search, but in search of the square root (i.e. the number that multiplied by itself equals the original number).

# Working answer. Refer after trying it out

``````public static int computeRoot(int mid,int a){
if(mid==1){
return 0;
}
if(mid*mid == a ){
``````
• #### Kevin Guevara

Getting a stack overflow error but am not sure what is wrong.

``````//your code here
int c=0;
if(a==0){
System.out.println(a + " -> "+b);

}
else{
doStuff(a,b);
System.out.println(a + " -> "+b);
doStuff(c,b);
}
``````
• #### Zach

I don't know if this is how you thought for us to do it but this works for me.

int notUsed = 0;
for (int i = 1; i <= 3; i++){
if(i != a && i != b){
notUsed = i;
}
}
System.out.println(a + "->" + notUsed + " " + a + "->" + b + " " + notUsed + "->" + b);

• #### Peter Varsanyi

@Kevin: you never break the loop.
Hint: never reduces a, so it will never reach 0 to break the loop

• #### Ed Helms

Hi my script is correct (as i was able to test the correct output using another browser)

however im not clear on whats the submition rule for learneroo. Using javascript, does learneroo accept
console.log(Start + "->" + End)?

• #### Learneroo

@Ed, just use `print()` to print in Javascript. I'm going to add more help info soon.

• #### 曾國峻

Although I know the process of solution to the problem, I can't figure out how to transform into program. Could anyone give me some hint of how to program it?

• #### Learneroo

You can view the beginning of a solution here. The comments there can help guide you to a full solution.

• #### 曾國峻

Thanks, I have finished the challenge with your hint.

• #### mike

``````    public static void doStuff(int a){
solve(1, 3, a);
System.out.println();
}

static void solve(int a, int b, int elements){
``````
• #### greg

Any answers or help for this one? I find the backtracking code suggestion pretty vague... Thanks!

• #### Learneroo

See if the new hint help.

• #### greg

Thanks! Much clearer.
Greg

• #### jasson harsojo

static boolean groupSum(int index, int[] nums, int sum) {
//base case: check if reached sum
if(index==nums.length-1){
if(sum==0)return true;