Google Interview Question for Software Engineers


Country: United States




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

Does definition of unique mean unique across all files, or unique line within a particular file allowing duplicate lines in other file?

- practice April 13, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 2 vote

// ZoomBA
def get_all_unique( files ){
  from( files, set() ) -> {
    read($.o,true)
  }
}
// cool?
x = get_all_unique( [ 'samples/scratch.zm' , '/Codes/zoomba/wiki/tmp.zm' ]  )
println(x)

- NoOne April 12, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

#include <fstream>
#include <sstream>
#include <string>
#include <unordered_set>
#include <vector>

unordered_set<string> GetUniqueLines(vector<string>& str )
{
    unordered_set<string> res;
    for ( string filename: str ){
        std::string line;
        std::ifstream infile(filename);
        
        if ( !infile ) {
            continue;
        }
        
        while (std::getline(infile, line)) {
            std::istringstream iss(line);
            res.insert(line);
        }
    }
    return res;
}

- drolmal April 12, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

def findUniqueLines(path):
    files = os.listdir(path)
    commonlines = open(path+"\\"+files[0],"r").readlines()
    for i in range(1,len(files)):
        if len(commonlines) == 0:
            return "No common lines"
        commonlines = list(set(commonlines)&set(open(path+"\\"+files[i],"r").readlines()))
    if len(commonlines) == 0:
        return "No common lines"
    return commonlines

- ankitpatel2100 May 21, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

List<String> uniqueLines(List <String> fileNames){
List<String> list = new ArrayList<String>();
for(String s: fileNames){
BufferedReader rd = new FileReader (s);
while(rd.hasNext()){
if(!rd.contains()){
list.add(rd.readLine());
}
}
}
return list;
}

- kkk June 11, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

List<String> uniqueLines(List <String> fileNames){
	List<String>  list = new ArrayList<String>();
	for(String s: fileNames){
		BufferedReader rd = new FileReader (s);
		while(rd.hasNext()){
			if(!rd.contains()){
				list.add(rd.readLine());
			}			
		}
	}
	return list;
}

- kkk June 11, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

List<String> uniqueLines(List <String> fileNames){
List<String> list = new ArrayList<String>();
for(String s: fileNames){
BufferedReader rd = new FileReader (s);
while(rd.hasNext()){
if(!list.contains()){
list.add(rd.readLine());
}
}
if(rd !=null) rd.close();
}
return list;
}

- Anonymous June 11, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

$ cat * | sort -u

- Anonymous June 12, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

cat * | sort -u

- tibidikh June 12, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

# cat * | sort -u

- vu-doo-cok June 12, 2017 | 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