Epic Systems Interview Question for Software Engineer / Developers






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

static String replaceAllWords2(String original, String find, String replacement) {
    StringBuilder result = new StringBuilder(original.length());
    String delimiters = "+-*/(),. ";
    StringTokenizer st = new StringTokenizer(original, delimiters, true);
    while (st.hasMoreTokens()) {
        String w = st.nextToken();
        if (w.equals(find)) {
            result.append(replacement);
        } else {
            result.append(w);
        }
    }
    return result.toString();
}

- pondy April 11, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

what if we want to replace a string "fd.dc" ? we cannot do that using this right..

- Anonymous April 17, 2009 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

It can be done in O(N) time by using algorithms like KMP.

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

I do not think it is possible or a good idea to write KMP code during interivew

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

use strtok to split all words based on space. go through the word list forming the new char* replacing where ever strcmp yields a match.. quick and easy but may be not optimal..

- varun February 22, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

if the word to be replaced is way larger than the word itself how will this work...

- Anonymous February 28, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

The algorithm would work with combination of Vector and strtok.

- Cookie May 15, 2009 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

tr filter in unix does it for you.
I am not sure if interviewer was expecting you to write code in c or c++ / or he wanted to know whether u know stuff beyond c/c++.
whenever u get interviewed try to understand the intent of the question rather than just start writing code.

also, question may be ambigious so he expects you to ask all questions i.e. all edge cases.

in c++ .
we can use hashset to store all words encountered in sentence and replace the word that we want.

- sonu March 01, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

using strtok to split sounds good option but the spliting is not always based on space it can be , or something else hence to create the new char* can get tricky.

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

This is simple actually. Code is lil complicated but pseudo code can be written for this.

- Anon September 01, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

use Sieve of Eratosthenes algorithm.. it takes space in o(n) but its a linear time algorithm..

- Anonymous March 21, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

What if put all the words in a Queue and when we are dequeuing check for the word to changed? Split the words based on spaces and enqueue them.

- Tejaswi January 22, 2015 | 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