Pramp - mock interview experience

 
February 23, 2016

Read the article today from hackerRank blog on facebook:

http://venturebeat.com/2016/02/18/how-i-landed-a-google-internship-in-6-months/?utm_content=buffer5c137&utm_medium=social&utm_source=facebook.com&utm_campaign=buffer

Pramp - free mock interview website - Great! give it a try!

Julia never had chance to give other people code interview before, and then, she will have one on Pramp. Excited!

Algorithm for the interview being an interviewer:

Find The Duplicates

Given two arrays of US social security numbers: Arr1 and Arr2 of lengths n and m respectively, how can you most efficiently compute an array of all persons included on both arrays?
Solve and analyze the complexity for 2 cases:
1. m ≈ n - lengths are approximately the same
2. m ≫ n - one is much longer than the other
 
 Julia worked on the question by herself first, around 20 minutes (no coding) before she reads :
 
1. Brute force solution, time complexity: O(nm), go through two loops, in other words, go through Arr1, and for each element in Arr1, check if it is in Arr2. 
 
2. Can we do better than O(nm)? Of course. 
case 1: m ≈ n - lengths are approximately the same
  sort Arr1, it takes time O(nlogn); 
  and then, for each node in Arr2, find it is duplicated one in Arr1. Use binary search, each search takes O(logn), m elements, so time complexity is O(mlogn)
 
  So, time complexity in total: O(nlogn) + O(mlogn) ≈ O(nlogn), which is better than brute force one: O(nm) time complexity
  <-  Julia, you missed another important step: Ask if the arrays are sorted or not? 
  <-  Julia, if two arrays are sorted, what is the optimal time complexity? 
        Linear time <-  O(n+m) <- you missed the opportunity to ask yourself the question. 
 
What a fun night to play algorithm again. 

Pramp - mock interview experience的更多相关文章

  1. Pramp mock interview (4th practice): Matrix Spiral Print

    March 16, 2016 Problem statement:Given a 2D array (matrix) named M, print all items of M in a spiral ...

  2. leetcode & Mock Interview

    leetcode & Mock Interview https://leetcode.com/interview/ xgqfrms 2012-2020 www.cnblogs.com 发布文章 ...

  3. Eric Chen Mock Interview

    Given an array with integers. Find two non-overlapping subarrays A and B, which |SUM(A) - SUM(B)| is ...

  4. (Forward)5 Public Speaking Tips That'll Prepare You for Any Interview

    Landing a job interview is incredibly exciting –- and often terrifying. But fear not. There are clev ...

  5. Get the Job You Want(大学英语综合教程4课文)

    UNIT3-1 Harvey Mackay, who runs his own company, often interviews applicants for jobs. Here he lets ...

  6. HOW TO ANSWER: Tell Me About Yourself

    https://biginterview.com/blog/2011/09/tell-me-about-yourself.html There are some job interview quest ...

  7. geometric median

    The geometric median of a discrete set of sample points in a Euclidean space is the point minimizing ...

  8. How to crack interviews ...

    Code practice: Leetcode: www.leetcode.com HackerRank: www.hackerrank.com Topcoder: https://www.topco ...

  9. Careercup - Google面试题 - 5085331422445568

    2014-05-08 23:45 题目链接 原题: How would you use Dijkstra's algorithm to solve travel salesman problem, w ...

随机推荐

  1. jQuery -原生 如何互转

    今天研究源码的时候发现,不需要用get() 也能进行原生转换,使用原生方法. 原生- jQuery对象   var obj=document.xxx $(obj).css(); 也可以直接 $(doc ...

  2. 分享个 之前写好的 android 文件流缓存类,专门处理 ArrayList、bean。

    转载麻烦声明出处:http://www.cnblogs.com/linguanh/ 目录: 1,前序 2,作用 3,特点 4,代码 1,前序  在开发过程中,client 和 server 数据交流一 ...

  3. mvc 重定向的几种方式

    在RouteConfig添加一个简单的路由 //新增路由 routes.MapRoute( name: "Article", url: "Detial/{id}" ...

  4. Sql常用语句(3)

    --显示sql server现有的所有数据库 exec sp_helpdb --查看数据表设置的约束 exec sp_helpconstraint SubjectType --update selec ...

  5. jquery+ajax+struts2

    AJAX 是与服务器交换数据的艺术,它在不重载全部页面的情况下,实现了对部分网页的更新.编写常规的 AJAX 代码并不容易,因为不同的浏览器对 AJAX 的实现并不相同.这意味着您必须编写额外的代码对 ...

  6. 锐捷linux客户端常用命令(主要用来连接校园网或公司局域网)

     锐捷访问校园网,.sh脚本文件rjsu*.sh-u 用户名-P 密码-S 参数1保存密码参数0不保存密码   其实:  直接使用md5认证方式输入用户名密码并且配置好ip之后,重新打开网卡即可有一定 ...

  7. 【JS基础】数组

    filter() 返回数组中的满足回调函数中指定的条件的元素. array1.filter(callbackfn[, thisArg]) 对数组array1中的每个元素调用回调函数callbackfn ...

  8. CSS布局 -- 圣杯布局 & 双飞翼布局

    按照我的理解,其实圣杯布局跟双飞翼布局的实现,目的都是左右两栏固定宽度,中间部分自适应. 但在这里实现起来还是有一些区别的 [圣杯布局] 在这里,实现了左(200px) 右(220px) 宽度固定,中 ...

  9. no identity found Command /usr/bin/codesign failed with exit code 1 报错解决方法

    stackoverflow 的解决方法是 xcode->preference->account->view detail -> refresh the provisioning ...

  10. 苹果的MDM简介

    MDM(Mobile Device Management)移动设备管理,一般会用于企业管理其移动设备,鉴于iOS是比较封闭的系统很多的功能都难以实现,所以利用苹果的MDM可以达到远程控制设备,像远程定 ...