Adobe Interview Question for Software Engineers


Country: India
Interview Type: In-Person




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

def notpreschars(str1, str2):
		table = {}
		str = ""
		list1 = [i for i in str1]
		list2 = [j for j in str2]
		for i in list1:
			table[i] = count(i)
		for j in list2:
			table[j] = count(j)
		for k,v in table.iteritems():
			if v % 2 == 1:
			str = str+v
		return str

- revanth October 26, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Use a hashmap:
-the key is a character; the value is a boolean.
-iterate through the second string and insert each character into the map, assigning it a value of false. If the character is already in the map, ignore it.
-iterate through the first string and check to see if all of its characters exist in the map. If a character exists in the map change the value to 'true'. If it doesn't, keep it false.
-iterate through the map and print all the characters with a value of 'false'

- Jim October 26, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

your output missing 'n' as well.
however easy way to do this is put the first string in a hash-table (char by char) and then loop over the chars of the second string to determine whether they are in the hashtable or not O(1) for every char so that makes the total of about O(n+m) i believe. where n is string1 length and m is string2 length.

- psk October 26, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

#include <stdio.h>
#include <string.h>

int found(char c,char *x)
{
int i =0;
for(i=0;i<strlen(x);i++){
if(c == x[i]){
return 1;
}
}

return -1;
}

void print_char(char *x,char *y)
{
int i = 0;
for(i=0;i<strlen(y);i++){
if(found(y[i],x) != 1){
printf("%c",y[i]);
}
}

printf("\n");
}

int main()
{
char x[50] , y[50];
scanf("%s",x);
scanf("%s",y);
print_char(x,y);
return 0;
}

- Anonymous October 26, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

#include <stdio.h>
#include <string.h>

int found(char c,char *x)
{
int i =0;
for(i=0;i<strlen(x);i++){
if(c == x[i]){
return 1;
}
}

return -1;
}

void print_char(char *x,char *y)
{
int i = 0;
for(i=0;i<strlen(y);i++){
if(found(y[i],x) != 1){
printf("%c",y[i]);
}
}

printf("\n");
}

int main()
{
char x[50] , y[50];
scanf("%s",x);
scanf("%s",y);
print_char(x,y);
return 0;
}

- Aniket October 26, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

In this question, we must first convert second string into a set of characters so that we only check for a characters presence in first string only once. Below is code which does so,

import collections
 
def printNotInFirstStr(str1, str2):
	# remove duplicate characters from str2
	x = collections.OrderedDict.fromkeys(list(str2))
	for i in x:
		if i[0] not in str1:
			print(i[0])

>>> x = "apple"
>>> y = "aeroplane"
>>> 
>>> printNotInFirstStr(x, y)
r
o
n

Similar logic can be coded in C, with some more code for creating a kind of set or map.

- pravar3088 November 07, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

public static void checkDiff(String str1, String str2) {
int[] hash = new int[27];

for(int i=0; i<str1.length(); i++) {
hash[str1.charAt(i) - 'a'] = 1;
}

for(int i=0; i<str2.length(); i++) {
if(hash[str2.charAt(i) - 'a'] != 1) {
System.out.println(str2.charAt(i));
}
}
}

- darshan.androidapp March 12, 2016 | 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