Facebook 电面 02/01 2018

Posted jxr041100

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Facebook 电面 02/01 2018相关的知识,希望对你有一定的参考价值。

/*Welcome to Facebook!

This is just a simple shared plaintext pad, with no execution capabilities.

When you know what language you‘d like to use for your interview,
simply choose it from the dropdown in the top bar.

Enjoy your interview!

hello!

 1 2 3 5 2 4 6 -> 4*/
 
#include <vector>
#include <iostream>
  
int findLongestContinousSequence(vector<int>&nums)
{
  if(nums.size()) return 0;
  int cnt = 1;
  int max_cnt = 1;
  for(int i = 1;i<nums.size();i++)
  {
    if(nums[i]>=nums[i-1]) cnt++;
    else cnt= 1;
    max_cnt = max(max_cnt,cnt);
  }
  return max_cnt;
}


dp[i] = dp[j]+1;//for j between [0,i] if nums[i]>nums[j];


int main()
{
  vector<int> nums = {7,3,5,8,9,2,3,10};
  int cnt = findLongestContinousSequence(nums);
  cout << cnt << endl;
}

dot product

v1 = [1, 0, 1]
v2 = [1, 1, 1]

v1 dp v2 = 1 + 0 + 1= 2

struct node
{
  int idx
  int val;
  node(int _idx,int _val)
  {
    idx = _idx;
    val = _val;
  }
}
  
bool get_data(vector<node>&data1,vector<node>&data2)
  

class dotProduct
{
     int dot_product()
     {
        vector<node> dat1,dat2;
        int sum = 0;
        get_data(dat1,dat2)
        
        int idx1 = 0,idx2 = 0;
        // O(min(dat1.size(),dat2.size())
        while(idx1<dat1.size() && idx2<dat2.size())
        {
           if(dat1[idx1].idx == dat2[idx2].idx) sum += dat1[idx1].val*dat2[idx2].val;
           else if (dat1[idx1].idx == dat2[idx2].idx) idx1++;
           else idx2++;
        }               
       return sum;
     }
}
  

 

以上是关于Facebook 电面 02/01 2018的主要内容,如果未能解决你的问题,请参考以下文章

记一次阿里电面经历

Facebook Graph API event-id/comments?since=2014-02-01&until=2014-02-10 ,日期过滤器无效

秋招提前批总结

Oracle 电面

Dropbox电面面经

面经-阿里Lazada电面