Intuit Interview Question for Quality Assurance Engineers


Country: United States
Interview Type: Phone Interview




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

The implementation in C#, but I think there are similar to Java data structures

public static string EliminateStopWords(string val)
        {
            var stopWords = new HashSet<string>() { "a", "be", "to", "the", "that", "this", "or" };
            var arrVal = val.Split(' ');
            var j = 0;
            for (var i = 0; i < arrVal.Length; i++)
            {
                if (!stopWords.Contains(arrVal[i].ToLower()))
                {
                    arrVal[j] = arrVal[i];
                    j++;
                }
            }
            return string.Join(" ", arrVal, 0, j);
        }

- nemestnyi November 14, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
1
of 1 vote

public static String eliminateStopWords(String str, String[] stopWords) {

		Set<String> hashStopWords = new HashSet<String>();
		for (String arrStr : stopWords) {
			hashStopWords.add(arrStr);
		}

		String[] splitStr = str.split(" ");
		int j = 0;
		for (int i = 0; i < splitStr.length; i++) {
			if (!hashStopWords.contains(splitStr[i].toLowerCase())) {
				splitStr[j] = splitStr[i];
				j++;

			}
		}
		System.out.println(StringUtils.join(splitStr, " ", 0, j).toString());
		return StringUtils.join(splitStr, " ", 0, j).toString();
	}
}

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

Store stop words in hashset. Split the string using str.split(" ") and iterate over the returned array. If an element in the array is present in the hashset (check using hashset.contains(element)), make it null or "". Display final string by concatenating each element of the array with a whitespace in between.

- Anonymous November 14, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Dont forget to lowercase each element before checking with the hashset like I did :P

- Anonymous November 14, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

C++ version:

string remove_unnecessary_words(string &s1, vector<string> &words) {
unordered_set<string> ht;
string s2;
string word_tmp;

for (int i = 0; i < words.size(); i++) {
auto it = ht.find(words[i]);

if (it == ht.end()) {
ht.insert(words[i]);
}
}

for (int i = 0; i < s1.size(); i++) {
if (s1[i] == ' ') {
auto it = ht.find(word_tmp);

if (it == ht.end()) {
s2 += word_tmp;
s2 += " ";
}

word_tmp = "";
}
else {
word_tmp += s1[i];
}
}

return s2;
}

- Gerald November 14, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.StringTokenizer;


public class UnusedWords {
	public static void main(String[] args) {
		String s= "To be or not to be - that is the question: Whether it is nobler in the mind to suffer, the slings and arrows of outrageous fortune. Or to take up arms against a sea of troubles, and by opposing end them";
           StringTokenizer st = new StringTokenizer(s," ");
            List<String> ls = new ArrayList<>();
       
         HashSet<String >  hst =  new HashSet<String >(); 
         hst.add("a" );
         hst.add("be");
         hst.add("that" );
         hst.add("the" );
         hst.add("this" );
         hst.add( "or" );
         hst.add( "to" );
  
         
  while (st.hasMoreTokens()){
	  String Currentword = st.nextToken();
	  if(!hst.contains(Currentword.toLowerCase())){
		  
		  ls.add(Currentword.toLowerCase());
		  
	  }  
  }
		for(String srt:ls){
			System.out.println(srt.toString());
	
			
		}
	}

}

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

public class Example1 {

public static void main(String[] args)
{
String str="To be or not to be - that is the question: Whether it is nobler in the mind to suffer, the slings and arrows of outrageous fortune. Or to take up arms against a sea of troubles, and by opposing end them";
List<String> lst = new ArrayList<String>();
String[] strArr = str.split(" ");
for(String str1 : strArr)
{
lst.add(str1);
}
str = "a,be,to,the,that,this,or,To";
strArr = str.split(",");
List<String> remlst = new ArrayList<String>();
for(String str1 : strArr)
{
remlst.add(str1);
}

lst.removeAll(remlst);
StringBuilder finalSrt = new StringBuilder();
for(String str2 : lst)
{
finalSrt.append(str2).append(" ");
}
System.out.print(finalSrt);
}

}

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

Here's the java version using String array

public class InterviewPpn {
	public static void main(String[] args){
		String input = "To be or not to be - that is the question: Whether it is nobler in the mind to suffer, the slings and arrows of outrageous fortune. Or to take up arms against a sea of troubles, and by opposing end them";
		
		String[] stopWordList = {"a","or","to","be","that","the","this"};
		String[] token = input.split(" ");
		StringBuffer finalString = new StringBuffer();
		Boolean flag = false;
		for(int j=0;j<token.length;j++){
			String newToken = token[j].toLowerCase();
			for(int k =0;k<stopWordList.length;k++){
				if(newToken.equals(stopWordList[k])){
					flag = true;
				}
			}
			if(flag == false){
				finalString.append(token[j]+" ");
			}
			flag = false;
		}
		String output = finalString.toString();
		System.out.println("Final String: "+ output);
	}
}

- Vinoth Selvaraju December 15, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

we Can use removeall method provided by java.
we have to build two arraylist one for the Input words and second for the words to be removed and then simply use
arrList1.removeAll(arrList2);
now arrList1 will have the required output just print the result.

It will give the same time complexity as mentioned in above examples.

- amit deol February 19, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

One additional thing we need to do is to add all the lower case and upper case words together in the unnecessary list as the remove all method won't ignore the cases while removing.

- Manish March 10, 2014 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

import java.util.HashSet;
import java.util.Set;


public class stopWord {

	public static void main(String[] args) {

		Set<String> set = new HashSet<String>();
		String str = "to be or not to be - that is the question";
		String [] splitArray = str.split(" ");
		String stt = new String();
		set.add("a");set.add("be");set.add("to");set.add("the");set.add("that");set.add("this");set.add("or");
		
		for(int i=0; i< splitArray.length;i++){
			if(!set.contains(splitArray[i])){
				stt = stt + splitArray[i]+ " ";
			}
		}
		
		System.out.println(stt);
	}

}

- ak350d May 14, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

#!/usr/bin/env python3
"""
eliminate stop words
"""
def eliminate_stop_words(txt, stop_words):
  assert type(txt) is str, "txt must be str"
  assert type(stop_words) is set, "stop_words must be a set"
  return " ".join([word for word in txt.split() if not word in stop_words])
print(eliminate_stop_words("To be or not to be", set(["or"])))

- KB2 June 04, 2019 | 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