活跃农民
- 积分
- 342
- 大米
- 颗
- 鳄梨
- 个
- 水井
- 尺
- 蓝莓
- 颗
- 萝卜
- 根
- 小米
- 粒
- 学分
- 个
- 注册时间
- 2015-10-4
- 最后登录
- 1970-1-1
|
审核过了,来贴代码了
- /* ---------------- interview round 1 ---------------- */
- /*
- Edmonton — the northernmost big city in North America, known for its cold winters, petrochemical industry and ginormous shopping mall (21 water slides and a triple loop roller coaster) — is growing fast, increasingly youthful, and home to a thriving arts scene, including a sprawling annual fringe festival.
- The 52-year-old Citadel Theater, housed in a five-stage glass-and-brick downtown playhouse, tried developing shows for Broadway in its early years. But it largely got out of the game after a series of disappointments, including two plays, “A Life” and “Mister Lincoln,” that transferred in 1980 but then flopped, as well as “Pieces of Eight,” an ambitious musical adaptation of “Treasure Island” that sank at the Citadel in 1985.
- */
- var str="Edmonton — the northernmost big city in North America, known for its cold winters, petrochemical industry and ginormous shopping mall (21 water slides and a triple loop roller coaster) — is growing fast, increasingly youthful, and home to a thriving arts scene, including a sprawling annual fringe festival. The 52-year-old Citadel Theater, housed in a five-stage glass-and-brick downtown playhouse, tried developing shows for Broadway in its early years. But it largely got out of the game after a series of disappointments, including two plays, “A Life” and “Mister Lincoln,” that transferred in 1980 but then flopped, as well as “Pieces of Eight,” an ambitious musical adaptation of “Treasure Island” that sank at the Citadel in 1985.";
- // exact all the words out
- var list= str.match(/\w+\b/g);
- var map = new Map();
- for(var i=0;i<list.length;i++){
- var _temp = list[i].toLowerCase();
- if(map.get(_temp)){
- var n = map.get(_temp)+1;
- map.set(_temp, n);
- }else{
- map.set(_temp, 1);
- }
- }
- console.log(map);
- /* ---------------- interview round 2 ---------------- */
- // TO CREATE AN ARRAY CONTAINING THE FLIGHT NUMBERS CONTAINED IN TEXT1 AND TEXT2
- // flights = ["UA487", "AF185"]
- var text1 = "Hello, thank you for your booking with United Airlines. Your confirmation number is: FDU4OR. Your flight number is 0487. Your ticket number is 974723785."
- var text2 = "Thanks for booking on Air France. Your confirmation number is: FDU4OR. Your flight number: 185. Your ticket number is 923785."
- var airlineNames_airlineCodes_dataset = {
- "United Airlines": "UA",
- "Air France": "AF",
- "Air China": "CA",
- "JetBlue": "B6"
- }
- var flights=[];
- var airlineReg = /booking (?:with|on) (.*)\. Your confirmation number .* Your flight number(?:\:| is) (\d{3,4})\./;
- var result = text1.match(airlineReg);
- var r1 = result[1], r2=result[2];
- flights.push(airlineNames_airlineCodes_dataset[r1]+r2);
- result = text2.match(airlineReg);
- r1 = result[1], r2=result[2];
- flights.push(airlineNames_airlineCodes_dataset[r1]+r2);
- console.log(result[1]);
- console.log(result[2]);
- console.log(flights);
- /* ---------------- interview round 3 ---------------- */
- // input: aaabbcddeeefff
- // output: a3b2cd2e3f3
- // date regex match
- // 12-12-2017
- // 12/12/2017 17:15
- // ...
- // return the dates that matches
复制代码
第一轮
|
|