Vizury Interview Question for Software Engineer in Tests


Country: India
Interview Type: Phone Interview




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

from collections import OrderedDict
ip="Careercup is a good site . Careercup provides a lot of information ."
ipdict=OrderedDict()
iplist=ip.split(" ")
for i in iplist:
    if ipdict.has_key(i):
        ipdict[i]+=1
    else:
        ipdict[i]=1
for i in ipdict:
    if ipdict[i]==1:
        print i
        break

- ankitp2100 June 08, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

What does "first unique" mean? If first unique occurrence means just occurrence, then you need to use a queue.

This queue needs a push/pop method (which will be always performed together). A linked list which maintains pointer to the head should do fine.

- Originalbbb June 06, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Does it mean find first word in the file which is only occurrence in whole file?
2n complexity solution
Can use a map to mark occurrence for each word in the map. in next iteration find the word with count 1.
You can optimize it further to one iteration by maintaining additional metadata of words with 1 count

- pc June 06, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

For example :
"Careercup is a good site. Careercup provides a lot of information."

Suppose this sentence is their in file, then the function should return
"is"
as careercup is repeated.

- zammer June 07, 2015 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Just use Unix and the problem becomes very simple.

grep -o "Search" filename | uniq

- Amit June 06, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Use a LinkedHashSet (non java lovers, read up on it and implement a hash table mapping onto a doubly linked list ).


For opportunities in Waterloo/Toronto, Ontario area, ping me.

- RecruitingForSandvineCanada June 07, 2015 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

Use a LinkedHashSet (non java lovers, read up on it and implement a hash table mapping onto a doubly linked list ).


For opportunities in Waterloo/Toronto, Ontario area, ping me.

- RecruitingForSandvineCanada June 07, 2015 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Use a LinkedHashSet (non java lovers, read up on it and implement a hash table mapping onto a doubly linked list ).


For opportunities in Waterloo/Toronto, Ontario area, ping me.

- RecruitingForSandvineCanada June 07, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

LinkedHashSet?? How?

I think you meant HashMap.. right? Because we need to keep track of occurrence with the word.

- jenish.shah June 09, 2015 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

public static void main(String[] args) throws IOException {		
		BufferedReader reader=new BufferedReader(new FileReader(new File("C:\\Users\\shintog\\Desktop\\test.txt")));
		String s="";
		int temp=0;
		List<String> list=new ArrayList<>();
		String[] s2 = null;
		Map<String, Integer> map=new LinkedHashMap<>();
		while((s=reader.readLine())!=null){
			s2=s.split(" ");
		}
		for (int i = 0; i < s2.length; i++) {			
				if(!map.containsKey(s2[i])){
					map.put(s2[i], 1);
				}else{
					map.put(s2[i], map.get(s2[i]) +1);
				}			
		}
		
		for (Map.Entry<String , Integer> entry: map.entrySet()){
			if(entry.getValue()==1){
				list.add(entry.getKey());
			}
		}		
		System.out.println(list.get(0));
	}

- Shinto June 13, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

public static void main(String[] args) throws IOException {
		
		BufferedReader reader=new BufferedReader(new FileReader(new File("C:\\Users\\shintog\\Desktop\\test.txt")));
		String s="";
		int temp=0;
		List<String> list=new ArrayList<>();
		String[] s2 = null;
		Map<String, Integer> map=new LinkedHashMap<>();
		while((s=reader.readLine())!=null){
			s2=s.split(" ");
		}
		for (int i = 0; i < s2.length; i++) {			
				if(!map.containsKey(s2[i])){
					map.put(s2[i], 1);
				}else{
					map.put(s2[i], map.get(s2[i]) +1);
				}			
		}
		
		for (Map.Entry<String , Integer> entry: map.entrySet()){
			if(entry.getValue()==1){
				list.add(entry.getKey());
			}
		}
		
		System.out.println(list.get(0));
	}

- Shinto June 13, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

a=open("filename")
b=a.readlines()
a.close()
first_arr=[]
second_arr=[]
for line in b:
 for word in line.split():
  if word in first_arr:
   first_arr.remove(word)
   second_arr.append(word)
  else:
   first_arr.append(word)
print first_arr[0]

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

public static string FindUniqueString(string[] str)
{
	Dictionary<string, int> mydict = new Dictionary<string, int>();

	for (int i = 0; i < str.Length; i++)
	{
		if (!mydict.ContainsKey(str[i]))
		{
			mydict.Add(str[i],1);
		}
		else
		{
			mydict[str[i]]++;
		}
	}
	
	foreach (KeyValuePair<string,int> kvp in mydict)
	{
		if (kvp.Value == 1)
		{
			return kvp.Key;
		}
	}
	return "";

}

- gkr September 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