Yahoo Interview Question for Software Engineer / Developers






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

There's a similar problem with solutions under the Epic Systems section.

- soc November 02, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Does the first "Us" comes with the "?" without any spaces ? if it doesn't, then we can use StringTokenizer in java.

- vijgan November 11, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Does the first "Us" comes with the "?" without any spaces ? if it doesn't, then we can use StringTokenizer in java.

- vijgan November 11, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Cannot we just scan the string and append it in another string using stringBuffer....or guy is really looking for knowledge of string function??

- Anonymous November 20, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

just check every char in the string, if it is "u" and the coming char is "s" then replace them, simple subString(0,i)+"them"+subSting(i+1,length) can do it

- lindi720 November 23, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

what about this?

public class test_replace {
public static void main(String[] args)
{
String abc = "It always rains when the bus comes to us";

System.out.println(abc.replaceAll("(^| )us($| )"," them"));
}
}

- amishera December 23, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

very nice amishera.... we got to use regexpression here.... one small correct to above. We need to replace us with " them " and trim it. Else your solution will not work with the string "us It always rains when the us bus comes to us"

public class ReplaceTest {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		String abc = "us It always rains when the us bus comes to us";

		System.out.println(abc.replaceAll("(^| )us($| )"," them ").trim());
	}
} //

- master December 29, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Can we use back reference like \1 and \2? then we can use it like

abc.replace("(^|

)us($|

)", "\1them\2"));

- Anonymous January 16, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

\\bus\\b

package com.test;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class MatcherDemo {
    private static final String REGEX = "\\bus\\b";
    private static final String INPUT = "Us? It usually rains when bus comes to us";

    public static void main(String[] args) {
       Pattern p = Pattern.compile(REGEX);
       Matcher m = p.matcher(INPUT); // get a matcher object
       int count = 0;
       while(m.find()) {
           count++;
           System.out.println("Match number "+count);
           System.out.println("start(): "+m.start());
           System.out.println("end(): "+m.end());
       }
       
       String s = INPUT;
       System.out.println("Input: " + s);
       s = s.replaceAll(REGEX, "them");
       System.out.println("Output: " + s);
    }
}

- GD February 16, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

i think they must be intrested in unix shell script

- sudhir September 04, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

regex should be of type

private static final String REGEX = "\W+us\W+";
string.replaceAll(REGEX,"them");

- Anonymous September 23, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

public class usTOthem
{
public static void main(String[] args)
{
String st = "Us? It usually rains when bus comes to us";
String splitArr[] = st.split(" ");


for (int i = 0; i < splitArr.length; i++)
{
if(splitArr[i]=="us")
{
splitArr[i] = "them";
}
}

for(String modified: splitArr)
{
System.out.println(modified);
}
}

}
But still not working..help

- Java~Fool October 12, 2012 | 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