回复: 5
跳转到指定楼层
上一主题 下一主题
收起左侧

Pinterest 两次电面挂经

全局:

2018(4-6月) 码农类General 硕士 全职@pinterest - 内推 - 技术电面  | | Fail | 在职跳槽

注册一亩三分地论坛,查看更多干货!

您需要 登录 才可以下载或查看附件。没有帐号?注册账号

x
3月25日

Pinterst第一次电面,白人大叔

代码,就是计算器,加减小括号和字母变量,我没写完

结束之后又花了五十分钟在eclips上写完了,以下是正确的代码。造福大众

import java.io.*;
import java.util.*;

/*
* To execute Java, please define "static void main" on a class
* named Solution.
*
* If you need more classes, simply define them inline.

You are building an educational website and want to create a simple calculator for students to use. The calculator will only allow addition and subtraction of positive integers.

Given an expression string using the "+" and "-" operators like "5+16-2", write a function to parse the string and returns the result.



Sample input/output:
"6+9-12" => 3
"1+2-3+4-5+6-7" => -2




We also want to allow parentheses in our input. Given an expression string using the "+", "-", "(", and ")" operators like "5+(16-2)", write a function to parse the string and evaluate the result.

Sample input:
    expression1 = "5+16-((9-6)-(4-2))"
    expression2 = "22+(2-4)"

Sample output:
    evaluate(expression1) => 20
    evaluate(expression2) => 20



We want to allow students to use variables when entering expressions in the calculator. In addition to the formula string, we’ll add a new input to our function that holds variables and their values:
  {"e": 8, "y": 7, "pressure": 5}
and our string inputs now have a format like
      "(e+3)-temperature-pressure+2".

Evaluate the formula result as fully as possible using the input variables. It is possible that not all variables have known values, in which case you should preserve them in the output.

Sample input:
    variables = {"e": 8, "y": 7, "pressure": 5}
    expression = "(e+3)-temperature-pr
您好!
本帖隐藏的内容需要积分高于 188 才可浏览
您当前积分为 0。
使用VIP即刻解锁阅读权限或查看其他获取积分的方式
游客,您好!
本帖隐藏的内容需要积分高于 188 才可浏览
您当前积分为 0。
VIP即刻解锁阅读权限查看其他获取积分的方式
Unlock interview details and practice with AI
Curated Interview Questions from Top Companies
r);
        res+=flag*sign*corr_num;
      }else{
        if(!map.containsKey(substr)){
            map.put(substr,flag*sign);
          }else{
            map.put(substr,map.get(substr)+flag*sign);
          }
      }

    }


    // output

    StringBuilder sb = new StringBuilder();

    sb.append(res);
    for( String str:map.keySet() ){
      if(map.get(str)==0){
        continue;
      }

      if(map.get(str)==1){
        sb.append("+");
      }else if(map.get(str)==-1){
        sb.append("-");
      }else if(map.get(str)>0){
        sb.append("+");
        sb.append(map.get(str)+ "*");
      }else { //map.get(str)<0
        sb.append(map.get(str)+ "*");
      }

      sb.append(str);
    }

    return sb.toString();

  }

  private int getNum(String str,Map<String, Integer> var){

    return var.get(str);

  }

}


/*
Your previous Markdown content is preserved below:

Welcome to the Interview!



*/


我作大死,3.27申请了二次机会。

一个印度三哥,八年工作经验,问了最大的挑战什么的,交流一般。总是感觉他不满意我的回答,耽误了一些时间。

然后开始是很简单的矩阵找 长方形区域0,就是很简单啦,不过我没注意他的定义,耽误了一点时间。
然后就是求岛屿个数原题,我BFS,时间有点紧,强行写完了,一运行有bug。

过了两天通知挂了。

也是自己准备不足,岛屿个数都没写完。也是之前耽误时间了。我发现真的是耽误一点时间都不行。唉。继续努力。今天刚面完脸熟的电面,面完就把面试官举报了。下周一狗家昂塞。加油




评分

参与人数 2大米 +11 收起 理由
Galileo_Galilei + 10 给你点个赞!
tonyabracadabra + 1 很有用的信息!

查看全部评分


上一篇:脸熟社招SDE-full stack 一轮电面
下一篇:Palantir面经
🔗
 楼主| 北极猪一只 2018-4-20 10:08:54 | 只看该作者
全局:
您好!
本帖隐藏的内容需要积分高于 100 才可浏览
您当前积分为 0。
使用VIP即刻解锁阅读权限或查看其他获取积分的方式
游客,您好!
本帖隐藏的内容需要积分高于 100 才可浏览
您当前积分为 0。
VIP即刻解锁阅读权限查看其他获取积分的方式
Unlock interview details and practice with AI
Curated Interview Questions from Top Companies
回复

使用道具 举报

全局:
北极猪一只 发表于 2018-4-20 10:08
3.27的二次机会的代码

这题输出的是不规则形状corner的坐标么?
回复

使用道具 举报

🔗
weiqitoby600 2018-4-21 04:48:34 | 只看该作者
全局:
楼主为啥举报脸书面试官呀?:)
回复

使用道具 举报

🔗
 楼主| 北极猪一只 2018-4-22 03:20:33 | 只看该作者
全局:
tonyabracadabra 发表于 2018-4-21 04:12
这题输出的是不规则形状corner的坐标么?

不是,就是number of island
回复

使用道具 举报

🔗
 楼主| 北极猪一只 2018-4-22 03:21:34 | 只看该作者
全局:
weiqitoby600 发表于 2018-4-21 04:48
楼主为啥举报脸书面试官呀?:)

肉眼跑test case,把我的while看成if,非说我错,一个年轻阿三面试官,才两年工作经验
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册账号
隐私提醒:
  • ☑ 禁止发布广告,拉群,贴个人联系方式:找人请去🔗同学同事飞友,拉群请去🔗拉群结伴,广告请去🔗跳蚤市场,和 🔗租房广告|找室友
  • ☑ 论坛内容在发帖 30 分钟内可以编辑,过后则不能删帖。为防止被骚扰甚至人肉,不要公开留微信等联系方式,如有需求请以论坛私信方式发送。
  • ☑ 干货版块可免费使用 🔗超级匿名:面经(美国面经、中国面经、数科面经、PM面经),抖包袱(美国、中国)和录取汇报、定位选校版
  • ☑ 查阅全站 🔗各种匿名方法

本版积分规则

>
快速回复 返回顶部 返回列表