一亩三分地论坛

 找回密码
 获取更多干货,去instant注册!

一亩三分地官方iOS手机应用下载
查看: 1347|回复: 2
收起左侧

Cryptic Studios 新鲜的面经

[复制链接] |试试Instant~ |关注本帖
九号大头菜 发表于 2015-8-11 02:39:23 | 显示全部楼层 |阅读模式

2015(7-9月) 码农类 硕士 全职@Cryptic Studios - 网上海投 - 在线笔试 |Otherfresh grad应届毕业生

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

您需要 登录 才可以下载或查看,没有帐号?获取更多干货,去instant注册!

x
Cryptic Studios 新鲜的面经
网上海投[size=12.8000001907349px]Cryptic Studios[size=12.8000001907349px] 他们家的software engineer的职位,hr联系我说会有一个6~8小时的c test interview(OA), hr说最好能在5小时内完成,老师说被吓到了。昨天打开了链接, 题目确实是6~8小时的量,甚至是8+!做出了一道题,剩下一道木有时间了,于是草草交了。把题目发上来供大家参考,如果有面试它们家的小伙伴,可以提前看看题准备一两天,写出来了再面,个人觉得6~8小时搞定这两道题对于非大神级别的人来说还是很不科学的。
[size=12.8000001907349px]Speed is a factor, so the sooner you get it back to us, the better, but please do not send it back until it is complete.
[size=12.8000001907349px]

[size=12.8000001907349px]Standard C or C++ are the preferred languages for this test, but this is not an absolute requirement. Please use a compiler to test your code. Don't worry about dealing with illegal inputs or giant data sets. You should *not* use reference materials (other than language references) for this test. . 鐣欏鐢宠璁哄潧-涓浜╀笁鍒嗗湴
[size=12.8000001907349px]

[size=12.8000001907349px]Additionally, please specify how your test was compiled and run. If we cannot compile and run your test with a minimum of modification, it will receive a failing grade.
[size=12.8000001907349px]

[size=12.8000001907349px]

[size=12.8000001907349px]1. Write a function that accepts a string of digits and a target value as input parameters. This function should output the two input values followed by a string with +'s and *'s between the digits so the result of evaluating the mathematical expression is the target value. Pay attention to operator precedence. Note there may be more than one answer, it doesn't matter which one you print.
[size=12.8000001907349px]

[size=12.8000001907349px]Examples:
[size=12.8000001907349px]"1231231234",11353 -> "12*3+1+23*123*4"
[size=12.8000001907349px]"3456237490",1185 -> "3*4*56+2+3*7+490"
[size=12.8000001907349px]"3456237490",9191 -> "no solution"
[size=12.8000001907349px]. 1point3acres.com/bbs

[size=12.8000001907349px]

[size=12.8000001907349px]2. Write a function "void link(char **tiles)" that accepts a list of 'tiles' in the provided format below. It should link the tiles together sequentially in the order they are given, and print out the current count and arrangement of tiles at each step exactly as shown in the example output below, including the note about how far the tile had to be rotated.
[size=12.8000001907349px].1point3acres缃

[size=12.8000001907349px]A tile is a 2-by-2 square split into quadrants, where each quadrant has a number from 0 to 9. After the first tile, a tile can be legally placed if at least two of its quadrants match quadrants on adjacent tiles horizontally or vertically. A tile cannot be legally placed in a location if it would have fewer than two matching quadrants or has any quadrants that do not match horizontally or vertically. Tiles can be rotated, and tiles can be placed in offset positions as demonstrated with tile 9 in the third example. The inputs are always designed so there is only one place a tile will fit.
[size=12.8000001907349px]

[size=12.8000001907349px]Examples:
[size=12.8000001907349px]char *tiles1[] = {
[size=12.8000001907349px]        "11",     // 1
[size=12.8000001907349px]        "23",
[size=12.8000001907349px]        "",
[size=12.8000001907349px]        "44",     // 2
[size=12.8000001907349px]        "11",
[size=12.8000001907349px]        "",. Waral 鍗氬鏈夋洿澶氭枃绔,
[size=12.8000001907349px]        "16",     // 3
[size=12.8000001907349px]        "36",. visit 1point3acres.com for more.
[size=12.8000001907349px]        "",
[size=12.8000001907349px]        "51",     // 4
[size=12.8000001907349px]        "71",
[size=12.8000001907349px]        "",
[size=12.8000001907349px]        "46",     // 5
[size=12.8000001907349px]        "26",
[size=12.8000001907349px]        "",
. From 1point 3acres bbs[size=12.8000001907349px]        "14",     // 6
[size=12.8000001907349px]        "68",
[size=12.8000001907349px]        0};
[size=12.8000001907349px]

[size=12.8000001907349px]
. 鐗涗汉浜戦泦,涓浜╀笁鍒嗗湴
[size=12.8000001907349px]link(tiles1) prints:. visit 1point3acres.com for more.
[size=12.8000001907349px]
. From 1point 3acres bbs
[size=12.8000001907349px]6 tiles
[size=12.8000001907349px]link 1
[size=12.8000001907349px]11
[size=12.8000001907349px]23
[size=12.8000001907349px]
[size=12.8000001907349px]link 2
[size=12.8000001907349px]44 鏉ユ簮涓浜.涓夊垎鍦拌鍧.
[size=12.8000001907349px]11
[size=12.8000001907349px]11
[size=12.8000001907349px]23
[size=12.8000001907349px] . from: 1point3acres.com/bbs
[size=12.8000001907349px]link 3
. 鍥磋鎴戜滑@1point 3 acres[size=12.8000001907349px]44
[size=12.8000001907349px]11
[size=12.8000001907349px]1116.鏈枃鍘熷垱鑷1point3acres璁哄潧
[size=12.8000001907349px]2336
[size=12.8000001907349px]
[size=12.8000001907349px]link 4
[size=12.8000001907349px]  44
[size=12.8000001907349px]5111
[size=12.8000001907349px]711116
[size=12.8000001907349px]  2336
[size=12.8000001907349px]
[size=12.8000001907349px]link 5 // note this tile had to be rotated 180 degrees clockwise. Waral 鍗氬鏈夋洿澶氭枃绔,
[size=12.8000001907349px]  44
[size=12.8000001907349px]5111
[size=12.8000001907349px]71111662 鏉ユ簮涓浜.涓夊垎鍦拌鍧.
[size=12.8000001907349px]  233664
[size=12.8000001907349px]
[size=12.8000001907349px]link 6 // note this tile had to be rotated 270 degrees clockwise
[size=12.8000001907349px]  4448
[size=12.8000001907349px]511116
[size=12.8000001907349px]71111662. From 1point 3acres bbs
[size=12.8000001907349px]  233664
[size=12.8000001907349px]
[size=12.8000001907349px]
[size=12.8000001907349px]

[size=12.8000001907349px]
. 鐗涗汉浜戦泦,涓浜╀笁鍒嗗湴
[size=12.8000001907349px]char *tiles2[] = {
[size=12.8000001907349px]        "12",        // 1
[size=12.8000001907349px]        "34",
[size=12.8000001907349px]        "",
[size=12.8000001907349px]        "36",        // 2-google 1point3acres
[size=12.8000001907349px]        "15",. 鐣欏鐢宠璁哄潧-涓浜╀笁鍒嗗湴
[size=12.8000001907349px]        "",
[size=12.8000001907349px]        "56",        // 3
[size=12.8000001907349px]        "78",
[size=12.8000001907349px]        "",
[size=12.8000001907349px]        "78",        // 4
[size=12.8000001907349px]        "90",
[size=12.8000001907349px]        "",
[size=12.8000001907349px]        "46",        // 5. 1point 3acres 璁哄潧
[size=12.8000001907349px]        "26",
[size=12.8000001907349px]        "",
[size=12.8000001907349px]        "88",        // 6
[size=12.8000001907349px]        "01",
[size=12.8000001907349px]        "",
[size=12.8000001907349px]        "93",        // 7
[size=12.8000001907349px]        "54",
[size=12.8000001907349px]        0};
[size=12.8000001907349px]

[size=12.8000001907349px]

[size=12.8000001907349px]link(tiles2) prints:
[size=12.8000001907349px]. 1point3acres.com/bbs

[size=12.8000001907349px]7 tiles
[size=12.8000001907349px]link 1
[size=12.8000001907349px]12
[size=12.8000001907349px]34
[size=12.8000001907349px]
. 涓浜-涓夊垎-鍦帮紝鐙鍙戝竷
[size=12.8000001907349px]link 2 // note this tile had to be rotated 180 degrees clockwise
[size=12.8000001907349px]5112
[size=12.8000001907349px]6334
[size=12.8000001907349px]. From 1point 3acres bbs

[size=12.8000001907349px]link 3 // note this tile had to be rotated 90 degrees clockwise
[size=12.8000001907349px]755112
[size=12.8000001907349px]866334
[size=12.8000001907349px]
. From 1point 3acres bbs

[size=12.8000001907349px]link 4 // note this tile had to be rotated 90 degrees clockwise
[size=12.8000001907349px]97755112
[size=12.8000001907349px]08866334
[size=12.8000001907349px]

[size=12.8000001907349px]link 5 // note this tile had to be rotated 270 degrees clockwise
[size=12.8000001907349px]97755112
[size=12.8000001907349px]08866334
[size=12.8000001907349px]   66
[size=12.8000001907349px]   42
[size=12.8000001907349px]
. more info on 1point3acres.com
[size=12.8000001907349px]link 6 // note this tile had to be rotated 90 degrees clockwise. 鐣欏鐢宠璁哄潧-涓浜╀笁鍒嗗湴
[size=12.8000001907349px]97755112
[size=12.8000001907349px]08866334
[size=12.8000001907349px]08 66
. 鍥磋鎴戜滑@1point 3 acres[size=12.8000001907349px]18 42
[size=12.8000001907349px]
. Waral 鍗氬鏈夋洿澶氭枃绔,
[size=12.8000001907349px]link 7 // note this tile had to be rotated 270 degrees clockwise
[size=12.8000001907349px]97755112
[size=12.8000001907349px]08866334
[size=12.8000001907349px]08 66 34. 鍥磋鎴戜滑@1point 3 acres
[size=12.8000001907349px]18 42 95
[size=12.8000001907349px]

[size=12.8000001907349px]

[size=12.8000001907349px]

[size=12.8000001907349px]

[size=12.8000001907349px]char *tiles3[] = {
[size=12.8000001907349px]        "11",     // 1
[size=12.8000001907349px]        "12",-google 1point3acres
[size=12.8000001907349px]        "",
[size=12.8000001907349px]        "12",     // 2
[size=12.8000001907349px]        "93",
[size=12.8000001907349px]        "",
[size=12.8000001907349px]        "93",     // 3
[size=12.8000001907349px]        "99",
[size=12.8000001907349px]        "",
[size=12.8000001907349px]        "39",     // 4
[size=12.8000001907349px]        "98",
[size=12.8000001907349px]        "",
[size=12.8000001907349px]        "95",     // 5. Waral 鍗氬鏈夋洿澶氭枃绔,
[size=12.8000001907349px]        "86",. 鐣欏鐢宠璁哄潧-涓浜╀笁鍒嗗湴
[size=12.8000001907349px]        "",. more info on 1point3acres.com
[size=12.8000001907349px]        "57",     // 6
[size=12.8000001907349px]        "66",
[size=12.8000001907349px]        "",
[size=12.8000001907349px]        "77",     // 7
[size=12.8000001907349px]        "57",
[size=12.8000001907349px]        "",
[size=12.8000001907349px]        "13",     // 8
[size=12.8000001907349px]        "24", 鏉ユ簮涓浜.涓夊垎鍦拌鍧.
[size=12.8000001907349px]        "",. from: 1point3acres.com/bbs
[size=12.8000001907349px]        "45",     // 9
[size=12.8000001907349px]        "47",
[size=12.8000001907349px]        "",
[size=12.8000001907349px]        "24",     // 10
[size=12.8000001907349px]        "39",. Waral 鍗氬鏈夋洿澶氭枃绔,
[size=12.8000001907349px]        0};. 1point3acres.com/bbs
[size=12.8000001907349px]

[size=12.8000001907349px]link(tiles3) prints:
[size=12.8000001907349px]
. 鐗涗汉浜戦泦,涓浜╀笁鍒嗗湴
[size=12.8000001907349px]10 tiles-google 1point3acres
[size=12.8000001907349px]link 1 鏉ユ簮涓浜.涓夊垎鍦拌鍧.
[size=12.8000001907349px]11
[size=12.8000001907349px]12 鏉ユ簮涓浜.涓夊垎鍦拌鍧.
[size=12.8000001907349px]
. Waral 鍗氬鏈夋洿澶氭枃绔,[size=12.8000001907349px]link 2
[size=12.8000001907349px]11
[size=12.8000001907349px]12
[size=12.8000001907349px]12
[size=12.8000001907349px]93
[size=12.8000001907349px]
[size=12.8000001907349px]link 3. From 1point 3acres bbs
[size=12.8000001907349px]11
[size=12.8000001907349px]12. Waral 鍗氬鏈夋洿澶氭枃绔,
[size=12.8000001907349px]12
[size=12.8000001907349px]93
[size=12.8000001907349px]93
[size=12.8000001907349px]99. 鐣欏鐢宠璁哄潧-涓浜╀笁鍒嗗湴
[size=12.8000001907349px]
[size=12.8000001907349px]link 4
[size=12.8000001907349px]11
[size=12.8000001907349px]12
[size=12.8000001907349px]12
[size=12.8000001907349px]93
[size=12.8000001907349px]9339. 1point 3acres 璁哄潧
[size=12.8000001907349px]9998
[size=12.8000001907349px]
[size=12.8000001907349px]link 5
[size=12.8000001907349px]11.鏈枃鍘熷垱鑷1point3acres璁哄潧
[size=12.8000001907349px]12.鏈枃鍘熷垱鑷1point3acres璁哄潧
[size=12.8000001907349px]12
[size=12.8000001907349px]93
[size=12.8000001907349px]933995. 1point3acres.com/bbs
[size=12.8000001907349px]999886.1point3acres缃
[size=12.8000001907349px]
[size=12.8000001907349px]link 6
[size=12.8000001907349px]11
[size=12.8000001907349px]12
[size=12.8000001907349px]12
[size=12.8000001907349px]93
[size=12.8000001907349px]93399557
[size=12.8000001907349px]99988666
[size=12.8000001907349px] . 涓浜-涓夊垎-鍦帮紝鐙鍙戝竷
[size=12.8000001907349px]link 7
[size=12.8000001907349px]11
[size=12.8000001907349px]12
[size=12.8000001907349px]12    77
[size=12.8000001907349px]93    57
[size=12.8000001907349px]93399557
[size=12.8000001907349px]99988666
[size=12.8000001907349px]
[size=12.8000001907349px]link 8
[size=12.8000001907349px]1113
[size=12.8000001907349px]1224
[size=12.8000001907349px]12    77
[size=12.8000001907349px]93    57
[size=12.8000001907349px]93399557
[size=12.8000001907349px]99988666
[size=12.8000001907349px]
[size=12.8000001907349px]link 9. from: 1point3acres.com/bbs
[size=12.8000001907349px]1113
[size=12.8000001907349px]122445
[size=12.8000001907349px]12  4777
[size=12.8000001907349px]93    57
[size=12.8000001907349px]93399557
[size=12.8000001907349px]99988666
[size=12.8000001907349px]
[size=12.8000001907349px]link 10
[size=12.8000001907349px]1113
[size=12.8000001907349px]122445. 1point 3acres 璁哄潧
[size=12.8000001907349px]12244777
[size=12.8000001907349px]9339  57. 1point 3acres 璁哄潧
[size=12.8000001907349px]93399557
[size=12.8000001907349px]99988666
[size=12.8000001907349px]祝各位好运~🍀
鏉ユ簮涓浜.涓夊垎鍦拌鍧.

swing 发表于 2015-8-11 03:51:57 | 显示全部楼层
关注一亩三分地公众号:
Warald_一亩三分地
谢谢分享,虽然我不会C的面试~
回复 支持 反对

使用道具 举报

huangsilion 发表于 2015-8-12 03:44:52 | 显示全部楼层
关注一亩三分地微博:
Warald
public static String calculation(String str, int target) {                 String n = "no solution";                 if (str == null || str.length() == 0)                         return n;                 int len = str.length();                 int sum = 0;                 String result = "";                 List<String> list = new ArrayList<String>();                 rec(0, len, result, str, target, list);                 if (list.size() > 0)                         return list.get(0);                 else                         return n;          }          public static void rec(int s, int len, String result, String str,                         int target, List<String> list) {                 if (s == len && calculate(result) == target)                         list.add(new String(result));                 for (int i = s; i < len; i++) {                         String temp = str.substring(s, i + 1);                         if (i + 1 != len) {                                 rec(i + 1, len, result + temp + "+", str, target, list);                                 rec(i + 1, len, result + temp + "*", str, target, list);                         } else                                 rec(i + 1, len, result + temp, str, target, list);                  }          }          public static int calculate(String s) {                 if (s == null)                         return 0;                 s = s.trim().replaceAll(" +", "");                 int length = s.length();                  int res = 0;                 long preVal = 0; // initial preVal is 0                 char sign = '+'; // initial sign is +                 int i = 0;                 while (i < length) {                         long curVal = 0;                         while (i < length && (int) s.charAt(i) <= 57                                         && (int) s.charAt(i) >= 48) { // int                                 curVal = curVal * 10 + (s.charAt(i) - '0');                                 i++;                         }                         if (sign == '+') {                                 res += preVal; // update res                                 preVal = curVal;                         } else if (sign == '*') {                                 preVal = preVal * curVal; // not update res, combine preVal &                                                                                         // curVal and keep loop                         }                         if (i < length) { // getting new sign                                 sign = s.charAt(i);                                 i++;                         }                 }                 res += preVal;                 return res;         }
回复 支持 反对

使用道具 举报

本版积分规则

请点这里访问我们的新网站:一亩三分地Instant.

Instant搜索更强大,不扣积分,内容组织的更好更整洁!目前仍在beta版本,努力完善中!反馈请点这里

关闭

一亩三分地推荐上一条 /5 下一条

手机版|小黑屋|一亩三分地论坛声明 ( 沪ICP备11015994号 )

custom counter

GMT+8, 2017-2-22 11:57

Powered by Discuz! X3

© 2001-2013 Comsenz Inc. Design By HUXTeam

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