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. 前端学PHP之PHP操作memcache

    × 目录 [1]安装 [2]连接 [3]增删改查[4]分布式[5]状态[6]安全[7]应用 前面的话 和访问mysql服务器类似,PHP也是作为客户端API访问memcached服务器的,所以同样需要 ...

  2. JavaScript知识点总结(命名规范,变量的作用域)

    命名规范 有人说JavaScript的宽容性是这个语言最糟糕的方面之一.比如说想把2个数字加在一起,JavaScript会把其中一个数字解析成字符串,那么就会得到一个奇怪的字符串,而不是2个数字的和. ...

  3. Javascript学习笔记1

    一.写在前面的话 之前一直没有系统的学习javascript,自己也是小白,很多东西感觉不会,从本篇起,自己会抽出时间来,慢慢学习,好好领会! 深知学习是一个漫长的过程,来不得急躁,不积跬步,无以至千 ...

  4. ASP.NET Core 中文文档 第四章 MVC(3.6.1 )Tag Helpers 介绍

    原文:Introduction to Tag Helpers 作者:Rick Anderson 翻译:刘浩杨 校对:高嵩(Jack) 什么是 Tag Helpers? Tag Helpers 提供了什 ...

  5. 仓位管理 – 1.理论篇

    看到文章标题中的"仓位管理",读者可能会认为它只适用于股市投资.其实不然.只要是投资都涉及到风险.回报率.投资额度,都会涉及到仓位管理.再者,人生本身就带着无数的抉择.风险和回报, ...

  6. React-Native学习系列(一)

    近段时间一直在忙,所以博客也没有更新,这两天我翻了一下写的这几篇博客,感觉写的都很片面,所以,我想重新写一个系列教程,从最基础的开始,来让大家更容易学会React-Native. 这个系列大部分只介绍 ...

  7. LINQ to SQL语句(17)之对象加载

    对象加载 延迟加载 在查询某对象时,实际上你只查询该对象.不会同时自动获取这个对象.这就是延迟加载. 例如,您可能需要查看客户数据和订单数据.你最初不一定需要检索与每个客户有关的所有订单数据.其优点是 ...

  8. Sqlserver调用api

    虽然使用sqlserver去调用服务接口的情况比较少,但也可以去了解下对应的使用情况 一.首先要开启组件的配置 sp_configure ; GO RECONFIGURE; GO sp_configu ...

  9. JDBC_part3_批处理_事务_元数据

    本文为博主辛苦总结,希望自己以后返回来看的时候理解更深刻,也希望可以起到帮助初学者的作用. 转载请注明 出自 : luogg的博客园 谢谢配合! JDBC_day03 String a = " ...

  10. openresty 前端开发入门一

    OpenResty ™ 是一个基于 Nginx 与 Lua 的高性能 Web 平台,其内部集成了大量精良的 Lua 库.第三方模块以及大多数的依赖项.用于方便地搭建能够处理超高并发.扩展性极高的动态 ...