## Interview Question for SDE1s

Country: India

Comment hidden because of low score. Click to expand.
2
of 2 vote

IMO, No there is noway for you to parse a given string without any further information. Interviewer is either looking for some insight how you deal with it by probing further question OR you haven't shared the context on which the question was raised.

Plain string of integer can be permuted any number of times and each outcome can be single / double or any subset of string.

Comment hidden because of low score. Click to expand.
0
of 0 vote

What is the input given? Just the string?

Comment hidden because of low score. Click to expand.
0
of 0 vote

Yes, just a string and no other info given

Comment hidden because of low score. Click to expand.
0
of 0 vote

class MyClass
{
public static void main(String [] args)
{

String s="2153";
String[] strArr=s.split("");
for (int i=0 ; i<strArr.length; i++){
if (i%2!=0 || i == strArr.length-1){
System.out.println(strArr[i]);
}else{

System.out.println(strArr[i]+strArr[i+1]);
i++;
}

}
}

Comment hidden because of low score. Click to expand.
0
of 0 vote

``````class MyClass
{
public static void main(String [] args)
{

String s="2153";
String[] strArr=s.split("");
for (int i=0 ; i<strArr.length; i++){
if (i%2!=0 || i == strArr.length-1){
System.out.println(strArr[i]);
}else{

System.out.println(strArr[i]+strArr[i+1]);
i++;

}

}``````

Comment hidden because of low score. Click to expand.
0
of 0 vote

How will you know in 2815.. to find the single digit or double digit, do you need to find the permutation ?

Comment hidden because of low score. Click to expand.
0
of 0 vote

class HelloWorld
{
public static void main(String [] args)
{

String s="2153";
String[] strArr=s.split("");
for (int i=0 ; i<strArr.length; i++)
{
if (i%2!=0 || i == strArr.length-1)
{

System.out.println(strArr[i]+strArr[i+1]);
}
else
{

System.out.println(strArr[i]);

}

}

}

Comment hidden because of low score. Click to expand.
0
of 0 vote

class HelloWorld
{
public static void main(String [] args)
{

String s="2153";
String[] strArr=s.split("");
for (int i=0 ; i<strArr.length; i++)
{
if (i%2!=0 || i == strArr.length-1)
{

System.out.println(strArr[i]+strArr[i+1]);
}
else
{

System.out.println(strArr[i]);

}

}

}

Comment hidden because of low score. Click to expand.
0
of 0 vote

String s="2153";
String[] strArr=s.split("");
for (int i=0 ; i<strArr.length; i++)
{
if (i%2!=0 || i == strArr.length-1)
{

System.out.println(strArr[i]+strArr[i+1]);
}
else
{

System.out.println(strArr[i]);

}

}

Comment hidden because of low score. Click to expand.
0
of 0 vote

class HelloWorld
{public static void main(String [] args)
{String s="2153";
String[] strArr=s.split("");
for (int i=0 ; i<strArr.length; i++)
{if (i%2!=0 || i == strArr.length-1)
{System.out.println(strArr[i]+strArr[i+1]);
}
else
{System.out.println(strArr[i]);}}}}

Comment hidden because of low score. Click to expand.
0
of 0 vote

class HelloWorld
{public static void main(String [] args)
{String s="2153";
String[] strArr=s.split(" ");
for (int i=0 ; i<strArr.length; i++)
{if (i%2!=0 || i == strArr.length-1)
{System.out.println(strArr[i]+strArr[i+1]);
}
else
{System.out.println(strArr[i]);}}}}

Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

### Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

### Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.