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.

- hprem991 June 03, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

What is the input given? Just the string?

- data_freak June 03, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Yes, just a string and no other info given

- coolcoder3 June 03, 2016 | Flag Reply
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++;
}

}
}

- Chinmaya Das June 21, 2016 | Flag Reply
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++;
    			
    		}
    		
    	}

- Chinmaya Das June 21, 2016 | Flag Reply
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 ?

- hiteshp2489 July 27, 2016 | Flag Reply
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]);

}

}

}

- RITESH JAIN October 04, 2016 | Flag Reply
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]);

}

}

}

- RITESH JAIN October 04, 2016 | Flag Reply
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]);

}

}

- RITESH JAIN October 04, 2016 | Flag Reply
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]);}}}}

- RITESH JAIN October 04, 2016 | Flag Reply
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]);}}}}

- RITESH JAIN October 04, 2016 | Flag Reply


Add a Comment
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.

Learn More

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.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More