2016-05-13-NimbleRx 面试题

第一个面试工程师

Dana (Software Engineer) 8:30 - 9:45
很资深的工程师,做过开发和管理, 用过c++, python 之类的开发语言。 现在开始转作java开发, 一开始给我讲了NimbleRx 公司的系统架构和她负责那一块东西。

  1. Two sum 变体,用hashMap来做,map.containsKey(sum - arr[i])
    Follow up: 如果不能用额外的空间
    我说 Arrays.sort, 然后用binary search, 她说,在binary search之前,你怎么sort array。 我就随便说了insert search 。她否定了,还是得用额外的空间,那我又说merge sort ,被否定后。 她说可以用 quick sort

  2. common father of two nodes in Binary tree
    这道题,我之前做过,临时想不起来方法, 只记得要保存访问过的node
    在问她要提示以后,勉强做出来了。

第二个面试工程师

Amy (Software Engineer) 9:45 - 1100 (7年工作经验) qa出身,IBM干过, 熟悉db2

主要问了很多测试的问题

例如,Textbox

各种测试的项目

1.test scenario : pharmacy, doctor, patient, driver , 的流程, 如何测试, 怎样保证正确性

 take picture 来验证是否收到货
  1. test an user registration page: username and password, username is an email address, password have a list of limitation

    • least 6 characters,
    • at least one Capital character,
    • 1 number
    • 1 low case
    • 1 special character
  2. test text box: (Country, unicode , utf-8, multi-line,

  3. test number: ( 360-553-2098, phone number? ) need to be calculate, the range of number ,

  4. how to evaluate the relation between developer and QA?

5.matrix (code, test cases, test plans)
1).valid test cases
2). invalid test cases
* a. data related vs non data related
* b. severity
* c. UI related or backend API
* d. module, domain,

中途进来一个人 Tyler

不是做技术的。 和他聊了会儿天。带我去取吃的食物。

Lunch (Engineering team) Yulei

lulei 是华人工程师,给我讲了公司的一些情况,一起吃饭,了解了一些相互的情况。 他给我介绍了公司的一些项目和开发的情况: 既做Node.js+ Express + MongoDB, 又做 Java + spring + Hibernate + mysql, 服务器部署到 AWS 的开发(s3 + Elastic Beanstalk)

第三个面试工程师

Alan (Software Engineer)1:00 - 2:00

出了两道题

  1. isValidXml (List<Tag> list)
class  Tag {
    String  getTageName();  // return the tag, ex, html
     boolean isOpen();
     boolean isClose();
}

<html> <body> </body> </html>
这道题很类似LeetCode Valid Parentheses

isValidXml (List<Tag> list ) {
  Stack<Tag> st = new Stack<Tag>();
  for (Tag tag : list ) {
     if ( tag.isOpen()) {
          st.push(tag.getTagName());
     }
    if (tag.isClose()  && st.peek() == tag.getTagName()) {
       st.pop();
     } else {
      return false;
     }
  }
  return st.size() == 0; 
}
  1. Connect nodes at same level
    问他要了提示, 磕磕巴巴写完程序

// Java program to connect nodes at same level 
// NimbleRx coding question 
// Date: 2016-05-12

// A binary tree node
class Node {

    int val;
    Node left, right, next;

    Node(int item) {
        val = item;
        left = null;
        right = null;
        next = null;
    }
}

public class ConnectedTree {

    static Node root;

    // set the next of root and calls helper recursively for other nodes
    void connectNodes(Node p) {
        p.next = null; // Set the next for root

        // recursively set the next for rest of the nodes
        helper(p);
    }

    // set next of all descendants of p.
    public void helper(Node p) {

        if (p == null) {
            return;
        }

        if (p.left != null) {
            p.left.next = p.right;
        }

        // set the next node for p's right child
        if (p.right != null) {
            if (p.next != null) {
                p.right.next = p.next.left;
            } else {
                p.right.next = null; // if p is the right most child at its
                                        // level
            }
        }

        // Set next for other nodes
        helper(p.left);
        helper(p.right);
    }

    public static void main(String args[]) {
        ConnectedTree tree = new ConnectedTree();
        tree.root = new Node(10);
        tree.root.left = new Node(8);
        tree.root.right = new Node(2);
        tree.root.left.left = new Node(1);
        tree.root.left.right = new Node(4);
        
        tree.root.right.left = new Node(7);
        tree.root.right.right = new Node(3);

        // set next nodes in all nodes
        tree.connectNodes(root);

        // Let us check the values of next nodes
        System.out.println("Check the next node in the ConnecteTree " );
        System.out.println("Print -1 if there is no next node :\n");
        
        int rootNext = root.next != null ? root.next.val : -1;
        System.out.println("next of " + root.val + " is " + rootNext);

        int leftNext = root.left.next != null ? root.left.next.val : -1;
        System.out.println("next of " + root.left.val + " is " + leftNext);

        int rightNext = root.right.next != null ? root.right.next.val : -1;
        System.out.println("next of " + root.right.val + " is " + rightNext);
        
        int leftLeftNext = root.left.left.next != null ? root.left.left.next.val : -1;
        System.out.println("next of " + root.left.left.val + " is " + leftLeftNext);  //4
        
        int leftRightNext = root.left.right.next != null ? root.left.right.next.val : -1;
        System.out.println("next of " + root.right.right.val + " is " + leftRightNext);  //7
        

    }

}

第四个面试官

Duy (Head of Engineering) 14:00 - 14:40

The interviewer asked me to sum (Collection<Object> objects). The objects are possible ( string, number, List, Set or HashMap). I need to check the objs’ type, and sum the values of the objects. Skip the strings of Objects.

Collection<Object>

1.245
“2.345"
List
HashMap<k, v>
Pojo  { 
          person {
               int id
               String name
   }

分两步做

  1. How to deal with List, Set, Map, refer to Check if Object is instance of String, HashMap, or HashMap[ ]
    obj.instanceOf();

2). How to deal with PoJO, refer to how to get fields from a pojo dynamically
You may use java reflection. For simplicity I assume your Employee calss only contains int field. But you can use the similar rules used here for getting float, double or long value. Here is a complete code -

package com.hustbill;

import java.lang.reflect.Field;
import java.util.List;

class Person {

    private int salary = 100;
    private int tips = 20;
    private int benefit = 25;
    private int cashBack = 30;
    
}

public class PojoDemo {

    public static void main(String[] args) throws NoSuchFieldException, IllegalAccessException {

        int sum = 0;
        Person Person = new Person();
        Field[] allFields = Person.getClass().getDeclaredFields();

        for (Field each : allFields) {

            if (each.getType().toString().equals("int")) {

                Field field = Person.getClass().getDeclaredField(each.getName());
                field.setAccessible(true);

                Object value = field.get(Person);
                Integer i = (Integer) value;
                sum = sum + i;
            }

        }

        System.out.println("Sum :" + sum);
    }

}

第四个是 Evance

Sr. Software Engineer 14:40 - 15:30

He asked me introduce my projects and architecture. Also, asked me to introduce infrastructure of ELK (ElasticSearch, Logstash, Kibana)

Reference

Connect nodes at same level

Method 1 (Extend Level Order Traversal or BFS)

Consider the method 2 of Level Order Traversal. The method 2 can easily be extended to connect nodes of same level. We can augment queue entries to contain level of nodes also which is 0 for root, 1 for root’s children and so on. So a queue node will now contain a pointer to a tree node and an integer level. When we enqueue a node, we make sure that correct level value for node is being set in queue. To set nextRight, for every node N, we dequeue the next node from queue, if the level number of next node is same, we set the nextRight of N as address of the dequeued node, otherwise we set nextRight of N as NULL.
Time Complexity: O(n)

Method 2 (Extend Pre Order Traversal)

This approach works only for Complete Binary Trees. In this method we set nextRight in Pre Order fashion to make sure that the nextRight of parent is set before its children. When we are at node p, we set the nextRight of its left and right children. Since the tree is complete tree, nextRight of p’s left child (p->left->nextRight) will always be p’s right child, and nextRight of p’s right child (p->right->nextRight) will always be left child of p’s nextRight (if p is not the rightmost node at its level). If p is the rightmost node, then nextRight of p’s right child will be NULL.

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 199,271评论 5 466
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 83,725评论 2 376
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 146,252评论 0 328
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 53,634评论 1 270
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 62,549评论 5 359
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 47,985评论 1 275
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 37,471评论 3 390
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,128评论 0 254
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 40,257评论 1 294
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,233评论 2 317
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,235评论 1 328
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 32,940评论 3 316
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 38,528评论 3 302
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,623评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 30,858评论 1 255
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 42,245评论 2 344
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 41,790评论 2 339

推荐阅读更多精彩内容

  • 心,总是漂浮不定。 人,要归属感,安全感,要很多东西,是很难满足的一种“高等生物”。 所以两千多年以来,...
    danch阅读 186评论 0 2
  • 今天算了算日子,9月份貌似00后就要到大学报道了。可是我明明还感觉自己前两年刚大学毕业,但是实际上我也已经26岁了...
    老毛zoo阅读 269评论 1 5
  • 今天看了一篇文章,有目标感的人都是有影响力的人!但目标感和目标是两个不同的目概念,匆匆对照了一下自己,就是典型的有...
    youcare33阅读 394评论 0 0
  • 小时候常常在黄昏的时分,出去走走,不为别的,只是想看看夕阳。它红红的脸映红了半边天。也温暖了整个世界,也...
    子静白白阅读 589评论 7 15
  • 嘿2016年下半年开始啦 这两天,我看到朋友圈很多伙伴都在告别上半年。 是的,告别过去,也意味着新生。过去的都已经...
    陈sir阅读 1,019评论 3 5