AppPerfect Interview Question for Software Engineers


Country: India
Interview Type: Written Test




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

Python Solution :

def isomorpheous(a,b):
	if len(a) != len(b):
		return False
	dicti = {}
	for i in xrange(len(a)):
		if a[i] in dicti:
			if b[i] != dicti[a[i]]:
				return False
		else:
			dicti[a[i]] = b[i]

	if len( dicti.values()) != len(set(dicti.values())):
		return False
	return True
		

print isomorpheous("abcd","zxyz")

- Naman Dasot April 20, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

#include<iostream>
using namespace std;
int main()
{
while(1)
{
char s1[10],s2[10];
int key=1;
cin>>s1;
cin>>s2;
int i=0,j,k,l,m;
while(s1[i])
{
j=0;
while(s1[j])
{
if(s1[j]==s1[i])
{
if(s2[j]!=s2[i])
{
cout<<"False";
key=0;
break;
}
}
else
{
if(s2[j]==s2[i])
{
key=0;
cout<<"False";
break;
}
}
j++;
}

if(key==0)break;


i++;
}
if(key)
cout<<"True";
}

}

- Tanvir Mahmud April 20, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

#include<iostream>
using namespace std;
int main()
{
while(1)
{
char s1[10],s2[10];
int key=1;
cin>>s1;
cin>>s2;
int i=0,j,k,l,m;
while(s1[i])
{
j=0;
while(s1[j])
{
if(s1[j]==s1[i])
{

if(s2[j]!=s2[i])
{
cout<<"False";
key=0;
break;
}
}
else
{
if(s2[j]==s2[i])
{
key=0;
cout<<"False";
break;
}
}
j++;
}

if(key==0)break;


i++;
}
if(key)
cout<<"True";
}

}

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

#include<iostream>
using namespace std;
int main()
{
while(1)
{
char s1[10],s2[10];
int key=1;
cin>>s1;
cin>>s2;
int i=0,j,k,l,m;
while(s1[i])
{
j=0;
while(s1[j])
{
if(s1[j]==s1[i])
{
if(s2[j]!=s2[i])
{
cout<<"False";
key=0;
break;
}
}
else
{
if(s2[j]==s2[i])
{
key=0;
cout<<"False";
break;
}
}
j++;
}

if(key==0)break;


i++;
}
if(key)
cout<<"True";
}

}

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

// ZoomBA
def is_isomorphic( s1, s2 ){
  if ( (l = size(s1))!= size(s2) ) return false 
  m = dict()
  for ( i : [0:l] ){
    if ( s1[i] @ m ){
      y = m[ s1[i] ]
    } else {
      y = m[ s1[i] ] = s2[i]
    }
    if ( y != s2[i] ) return false
  }
  true
}
println( is_isomorphic('','' ))  // true 
println( is_isomorphic('aabaac','xxtxxw' )) // true 
println( is_isomorphic('ac','xxt' )) // false 
println( is_isomorphic('acaa','xxtw' )) // false

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

import java.util.List;
import java.util.LinkedList;
import java.util.Map;


public class CheckIsomorphic {

public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub


String s1= "abca";
String s2 = "xyzx";
Map<Character, Integer> map = new LinkedHashMap<Character, Integer>();
Map<Character, Integer> map1 = new LinkedHashMap<Character, Integer>();
if(s1.length()!=s2.length()){
throw new IOException("Strings are not Isomorphic");
}
else {
for (int i = 0; i < s1.length(); i++) {
if(!map.containsKey(s1.charAt(i))){
map.put(s1.charAt(i), 1);
}
else {
map.put(s1.charAt(i), map.get(s1.charAt(i))+1);
}
}
for (int i = 0; i < s2.length(); i++) {
if(!map1.containsKey(s2.charAt(i))){
map1.put(s2.charAt(i), 1);
}
else {
map1.put(s2.charAt(i), map1.get(s2.charAt(i))+1);
}
}
}
System.out.println(map);
System.out.println(map1);
List<Integer> list = new LinkedList<Integer>();
List<Integer> list1 = new LinkedList<Integer>();
for (Map.Entry<Character,Integer> x: map.entrySet()) {
list.add(x.getValue());
}
for (Map.Entry<Character,Integer> x: map1.entrySet()) {
list1.add(x.getValue());
}
System.out.println(list.equals(list1));
}

}

- Vipul Agarwal April 23, 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