注册一亩三分地论坛,查看更多干货!
您需要 登录 才可以下载或查看附件。没有帐号?注册账号
x
刚面完MoPub 小组的面试回来。前端Full Stack的职位。这个组是做Mobile广告的,这个小公司是被收购进来的。准备了一晚上的面试,一个题目也没中。唉。
第一轮。Compose CSS:
#EEAABB -> EAB
#E0ACF0 -> DAE
这个真的有点奇怪,它是这样的:找2位数 E0跟它最近的一个双位数,比如E0跟它最近的是DD. 光是明白这个问题我就弄了半天,唉。总之当时写得一塌糊涂。后来回家写了下蛮容易的。
99... AA.... BB..... CC.... DD... EE ... FF
贴下回家写的代码:- package twitter;
- public class CssCompose {
- public static void main(String[] args) {
- String s = compose("#EECCFF");
- System.out.println(s);
- s = compose("#EACDF8");
- System.out.println(s);
- }
- public static String compose(String css) {
- String origin = css.substring(1);
- String ret = "#";
- for (int i = 0; i < 3; i++) {
- String color = origin.substring(i * 2, i * 2 + 2);
- char c = twoToOne(color);
- ret += c;
- }
- return ret;
- }
- // AA...BB...CC...DD...EE...FF
- // AE CA FA
- public static char twoToOne(String color) {
- char c1 = color.charAt(0);
- char c2 = color.charAt(1);
- if (c1 == c2) {
- return c1;
- }
- int d1 = getDig(c1);
- int d2 = getDig(c2);
- int diff = d2 - d1;
- // AE.
- if (Math.abs(diff) <= 8) {
- return c1;
- }
- if (d1 < d2) {
- return getChar(d1 + 1);
- } else {
- return getChar(d1 - 1);
- }
- }
- public static char getChar(int num) {
- if (num >= 0 && num <= 9) {
- return (char)('0' + num);
- }
- return (char)('A' + num - 10);
- }
- public static int getDig(char c) {
- if (c >= 'A' && c <= 'F') {
- return c - 'A' + 10;
- }
- return c - '0';
- }
- }
复制代码 第二轮:聊系搞搞也写完了吧。
中间有个午餐环节,午餐特别好吃。公司环境也非常漂亮,在SF市市中心。感觉过的可能性不大啊,求大家帮集气!
明天是PureStorage,后天是AirBnb,请大家帮我加油啊!
补充内容 (2017-10-2 05:13):
二天后得到消息,Fail。有点可惜。 |