IBM OA
Job title: 60321BR - Entry Level Software Engineer. 网上海投
题型: Video(5) + coding(3) = 8 questions.
1 Video behavior question:
1.How did you become interested in a position with our IBM team?
It's known to all that IBM is a famous company leading cutting-edge technology and changing the world. As a result, software engineer teams can work in a variety of areas which I think I could learn a lot from them. And the most important point is that IBM always put customers in the first place which shows this company culture is really amazing. So I believe IBM is definitely the best place to work in.
2.How do your areas of studies and experience make you a great candidate for our team?
My coursework and projects show a strong background in many aspects of software engineer including software development, web development and algorithms. Like in my latest SaaS web development experience, I took part in both frontend and backend development for searching and matching services. And with socket programming experience, I implemented a chat service, file transfer server and HTTP proxy server, which also shows my knowledge in Internet Protocol.
My experiences also reflect my desire to become involved with challenging projects such as those offered by your company. In my latest full stack Agile development for SaaS application project, I worked as a scrum master to make detailed plans for each iteration, motive the whole team and communicate with clients and customers, which demonstrate my experience in team work.
And the most important is that I have a passion for wonderful products and like the creative ideas then put it into real. I always care about every detail for each product and want to make it perfect.
2 Video behavior question:
1.What are some new technologies that you are learning on your own?
I learn web development technology on my own like JavaScript/JQuery, Bootstrap, JSON, AngularJS, Node.js.
2.What do you see as the pros and cons of the technologies you are interested in?
Node.js:
pros: based on javascript, easy to learn, npm, the Node packaged modules has already become huge, and still growing. Is famous on github and there is a lot shared code.
Cons: Node.js doesn’t provide scalability. Dealing with relational database is a pain if you are using Node.
AngularJS:
pros: enable quick prototyping and delivery of dashboard-style. Development is fast and very expressive.
cons: basics are easy but high level skills are hard to learn. Scopes are easy to use but hard to debug
JQuery:
pros: easy of use, large library, strong opensource community, ajax support.
cons: functionality maybe limited.
3 Coding:
Fizz Buzz变形, input只是帮你完成了readline()的工作,需要自己进行split等
import java.util.*;
public class IBMOA1{
public String checkInt(String[] ipt){
int n = Integer.parseInt(ipt[0]);
int p = Integer.parseInt(ipt[1]);
int q = Integer.parseInt(ipt[2]);
StringBuilder rst = new StringBuilder();
for(int i=1;i<=n;i++){
int num = i;
if(num%p==0||num%q==0) rst.append("OUT");
while(num!=0){
int digt = num%10;
if(digt==p||digt==q){
rst.append("THINK");
break;
}else{
num /= 10;
}
}
if(rst.length()==0||rst.charAt(rst.length()-1)==',') rst.append(i);
rst.append(',');
}
rst.deleteCharAt(rst.length()-1);
return rst.toString();
}
public static void main(String[] args) {
// Scanner sc = new Scanner(System.in);
// String rl = sc.nextLine();
String rl = "7 2 3";
String[] ipt = rl.split(" ");
IBMOA1 test = new IBMOA1();
System.out.println(test.checkInt(ipt));
}
}
4 Coding:
我是用hashmap做的,input只是帮你完成了readline()的工作,需要自己进行split等.
import java.util.*;
public class IBMOA2 {
// public String filterDup(String ipt){
// String[] ipts = ipt.split("\\|");
// if(ipts.length==0) return "";
// String rst = ipts[0];
// HashMap<String, Integer> map = handleMessage(rst);
// for(int i=1;i<ipts.length;i++){
// HashMap<String,Integer> crt_map = handleMessage(ipts[i]);
// if(map.size()>crt_map.size()) continue;
// boolean eql = true, lrg = false;
// for(String ea : crt_map.keySet()){
// if(!map.containsKey(ea)){
// lrg = true;
// eql = false;
// break;
// }
// if(map.get(ea)<crt_map.get(ea)){
// lrg = true;
// eql = false;
// break;
// }
// if(map.get(ea)==crt_map.get(ea)) continue;
// eql = false;//two message are not duplicates
// }
// if(lrg){
// map = crt_map;
// rst = ipts[i];
// continue;
// }
// if(eql){
// if(rst.length()<=ipts[i].length()) continue;
// map = crt_map;
// rst = ipts[i];
// }
// }
// return rst;
// }
// private HashMap<String,Integer> handleMessage(String ipt){
// String[] ipts = ipt.trim().split(" +");
// HashMap<String,Integer> rst = new HashMap<>();
// for(String ea : ipts){
// char[] filter = ea.toLowerCase().toCharArray();
// StringBuilder after_filter = new StringBuilder();
// for(char c : filter){
// if(Character.isLetterOrDigit(c)) after_filter.append(c);
// }
// String crt = after_filter.toString();
// rst.put(crt,rst.getOrDefault(crt,0)+1);
// }
// return rst;
// }
public String filterDup(String ipt){
String[] ipts = ipt.split("\\|");
if(ipts.length==0) return "";
String rst = ipts[0];
int max_len = handleMessage(ipts[0]);
for(int i=1;i<ipts.length;i++){
int crt_len = handleMessage(ipts[i]);
if(crt_len>max_len){
rst = ipts[i];
max_len = crt_len;
}else if(crt_len == max_len&&rst.length()>ipts[i].length()){
rst = ipts[i];
max_len = crt_len;
}
}
return rst;
}
private int handleMessage(String ipt){
StringBuilder rst = new StringBuilder();
String[] ipts = ipt.split(" +");
for(String ea : ipts){
char[] filter = ea.trim().toLowerCase().toCharArray();
for(char c : filter){
if(Character.isLetterOrDigit(c)) rst.append(c);
}
}
return rst.length();
}
public static void main(String[] args) {
String ipt = "IBM cognitive computing|IBM 'cognitive' computing is a revolution| ibm cognitive computing|'IBM Cognitive Computing' is a revolution?";
IBMOA2 test = new IBMOA2();
System.out.println(test.filterDup(ipt));
}
}
5 Coding:
还是hashmap做的,input只是帮你完成了readline()的工作,需要自己进行split等.
import java.util.*;
public class IBMOA3 {
public String findManager(String ipt){
String[] ipts = ipt.split(",");
HashMap<String,String> map = new HashMap<>();
for(int i=0;i<ipts.length-2;i++){
String[] relation = ipts[i].split("->");
map.put(relation[1],relation[0]);
}
String person1 = ipts[ipts.length-1];
String person2 = ipts[ipts.length-2];
String p1Manager = person1;
String p2Manager = person2;
HashSet<String> set = new HashSet<>();
while(map.containsKey(p1Manager)||map.containsKey(p2Manager)){
if(map.containsKey(p1Manager)){
p1Manager = map.get(p1Manager);
if(!set.add(p1Manager)) return p1Manager;
}
if(map.containsKey(p2Manager)){
p2Manager = map.get(p2Manager);
if(!set.add(p2Manager)) return p2Manager;
}
}
return "";
}
public static void main(String[] args) {
IBMOA3 test = new IBMOA3();
String ipt1 = "Frank->Mary,Mary->Sam,Mary->Bob,Sam->Katie,Sam->Pete,Bob->John,Bob,Katie";
String ipt2 = "Sam->Pete,Pete->Nancy,Sam->Katie,Mary->Bob,Frank->Mary,Mary->Sam,Bob->John,Sam,John";
String ipt3 = "Tom->Mary,Mary->Bob,Mary->Sam,Bob->John,Sam->Pete,Sam->Katie,Pete,Katie";
System.out.println(test.findManager(ipt3));
}
}
6 Video question:
请解释一下刚刚那道题(#5 Coding)你的思路, 5min准备时间 10min回答时间。
- First I read this problem, I think I can use a tree structure to represent the relationship among all the employees. Then when it comes to find the manager to solve the conflicts between two employees, it's like finding a lowest common ancester for two nodes in the tree. Then we can use recursive method to find it starting from root node. Given a node, if the two target nodes exist in the different subtree, for example target 1 found in left subtree and target 2 found in right subtree, then this node is our result. Once we find two targets in the same subtree, then recursively go to corresponding subtree to find.
- However, in this problem, it's hard to use this method because we first need to build the employees tree from many random parent to children relations so the root node is not easy to find. In this problem, it says that a person can have only one manager, and our goal is to find their parent node. So for this problem, we could store the tree structure using a different way, which is hashmap key to value pattern, the key is the employee and the value is their manager, so in this way it's easy to find their parent node and there is no collision because one employee have only one manager. Then given one node, we could print all his managers level by level. After comparing target two nodes managers, starting from highest level manager, when we meet the first manager that is not same, we know the manager before him which is the last manager that is same will be the lowest common ancester.
- But, we still can optimize because imagining two target node is the left child and right child of their parent node, then we will waste a lot of space and time to print all their managers. So I come to a method that we move step by step from bottom to top to get their managers step by step. Using a hashset to store all the mangers that we meet, then the first manager that we can't add to this hashset, which means this manager has been visited before, is the result manager we need to find. In this way, we don't need to print all the managers and save space and time.
7 Video question:
请解释一下polymorphism,并举例说明
Polymorphism: Subclasses of a class can define their own unique behaviors and yet share some of the same functionality of the parent class.
Take the above coding problem as example, we have defined a parent class say Employee class, it has many variables and functions, for example, it has calculate salary, calculate work hour functions. Then for the manager, we can create a new class say Manager class, this manager class extends the employee class which mean employee class is the parent class. Then the manager class can inherit all the variables and functions that employee class have like calculate salary function, however, the manager class can add it's own functions say calculate the projects that he is in charge of. And also if the calculate salary function that inherited from parent class doesn't apply to manager class, then it can override it and customize it to satisfy its own requirements.
8 Video question:
剩下的第八题是看 watson 几个关于 software engineer职位的描述,然后选出自己最喜欢的前三个职位”