BrowserStack 面试经历 |第 7 组(在线编码问题)
问了三个问题。测试时长为 3 小时,在hackerearth 上进行。
1.编写一个sql解析器来正确解析特定表的查询。输入将由几行组成:第一行包含两个值,N 和 M,用逗号分隔。下一行包含表列的名称。接下来的 N 行将包含表格的 N 行(每列由逗号分隔)。之后,接下来的 M 行将包含您应该执行并返回其输出(每行一个)的 sql 查询的 where 子句。
表格输入将采用以下格式:
“身份证”、“姓名”、“日期”1、“纳伦德拉·穆迪”、“2014-10-23 12:21”。 . . 100、“拉胡尔·潘迪”、“2013-11-02 13:01”
查询输入将以下列格式给出:ID > 99 和 Name = “Rahul Pandely”
您应该评估查询并打印符合条件的行数。例如,上述查询的解决方案将是 1。
示例输入(纯文本链接)
6, 1
“ID”、“姓名”、“日期”、“分数”
1、《阿迪亚穆迪》、《2014-10-23 11:55》、20
2,”乌察夫穆迪”,”2014-10-24 15:18”,21
3,“乔恩·多伊”,“2014-10-23 02:51”,62
4、《美食吧》、《2014-10-23 12:00》、98
5、“拉胡尔·穆迪”、“2014-10-23 12:31”、61
6、“Umang JarJar”、“2014-10-23 11:21”、33
日期 > “2014-10-23 12:00”
示例输出(明文链接)
2
时间限制:每个输入文件 5 秒。
内存限制:256 MB
源限制:1024 KB
评分方案:如果任何测试用例通过,则给予评分。
允许的语言:C、C++、Clojure、C#、Go、Haskell、 Java、JavaScript、Objective-C、Perl、 PHP、 Python、Ruby
2.给定 HTTP 请求或响应标头,编写一个程序,根据输入打印“请求”或“响应”。
还,
如果是“响应”,请打印以下内容:
– 响应代码
– 正文的内容类型
如果是“请求”,请打印以下内容:
– Accept-Language 标头的值(如果存在)
– 请求的资源
例如:
给定输入:
获取 /index.html HTTP/1.1
主机:www.browserstack.com
输出将是:
要求
/index.html
示例输入(纯文本链接)
获取 /index.html HTTP/1.1
主机:www.browserstack.com
示例输出(明文链接)
要求
/index.html
时间限制:每个输入文件 5 秒。
内存限制:256 MB
源限制:1024 KB
评分方案:如果任何测试用例通过,则给予评分。
允许的语言:C、C++、Clojure、C#、Go、Haskell、 Java、JavaScript、Objective-C、Perl、 PHP、 Python、Ruby
3.您将获得如下示例所示的 Web 服务器日志行。您应该对其进行解析,并且对于文件中出现的所有 HTTP 代码,在每一行中打印出现的 HTTP 代码以及它出现的次数。输出应按出现的降序排序。
示例输入(纯文本链接)
185.12.15.89 - - [23/Nov/2014:03:33:03 -0500] “GET /ip HTTP/1.1” 503 323 “-” “curl/7.30.0”
185.12.15.93 - - [23/Nov/2014:03:33:07 -0500] “GET /ip HTTP/1.1” 503 323 “-” “curl/7.30.0”
54.243.188.61 - - [23/Nov/2014:03:33:08 -0500] “GET /ip HTTP/1.1” 503 323 “-” “check_http/v1.4.16 (nagios-plugins 1.4.16)”
87.255.53.44 - - [23/Nov/2014:03:33:52 -0500] “GET /ip HTTP/1.1” 503 323 “-” “curl/7.19.7 (universal-apple-darwin10.0) libcurl/ 7.19.7 OpenSSL/0.9.8r zlib/1.2.3”
87.255.53.45 - - [23/Nov/2014:03:33:54 -0500] “GET /ip HTTP/1.1” 503 323 “-” “curl/7.19.7 (universal-apple-darwin10.0) libcurl/ 7.19.7 OpenSSL/0.9.8r zlib/1.2.3”
208.52.180.116 - - [23/Nov/2014:03:33:58 -0500] “GET /ip HTTP/1.1” 503 323 “-” “curl/7.24.0 (x86_64-apple-darwin12.0) libcurl/ 7.24.0 OpenSSL/0.9.8y zlib/1.2.5”
185.12.15.90 - - [23/Nov/2014:03:33:58 -0500] “GET /ip HTTP/1.1” 503 323 “-” “curl/7.30.0”
208.52.145.6 - - [23/Nov/2014:03:33:58 -0500] “GET /ip HTTP/1.1” 503 323 “-” “curl/7.30.0”
185.12.15.78 - - [23/Nov/2014:03:33:58 -0500] “GET /ip HTTP/1.1” 503 323 “-” “curl/7.30.0”
185.12.15.91 - - [23/Nov/2014:03:33:58 -0500] “GET /ip HTTP/1.1” 503 323 “-” “curl/7.30.0”
208.52.180.23 - - [23/Nov/2014:03:33:58 -0500] “GET /ip HTTP/1.1” 503 323 “-” “curl/7.30.0”
185.12.15.80 - - [23/Nov/2014:03:33:58 -0500] “GET /ip HTTP/1.1” 503 323 “-” “curl/7.30.0”
216.126.44.86 - - [23/Nov/2014:03:33:58 -0500] “GET /ip HTTP/1.1” 503 323 “-” “curl/7.37.1”
185.12.15.94 - - [23/Nov/2014:03:33:58 -0500] “GET /ip HTTP/1.1” 503 323 “-” “curl/7.30.0”
185.12.15.76 - - [23/Nov/2014:03:33:58 -0500] “GET /ip HTTP/1.1” 503 323 “-” “curl/7.30.0”
208.52.180.115 - - [23/Nov/2014:03:33:59 -0500] “GET /ip HTTP/1.1” 503 323 “-” “curl/7.24.0 (x86_64-apple-darwin12.0) libcurl/ 7.24.0 OpenSSL/0.9.8y zlib/1.2.5”
185.12.15.72 - - [23/Nov/2014:03:33:59 -0500] “GET /ip HTTP/1.1” 503 323 “-” “curl/7.30.0”
185.44.128.160 - - [23/Nov/2014:03:33:59 -0500] “GET /ip HTTP/1.1” 503 323 “-” “curl/7.21.4 (universal-apple-darwin11.0) libcurl/ 7.21.4 OpenSSL/0.9.8z zlib/1.2.5”
87.255.53.54 - - [23/Nov/2014:03:33:59 -0500] “GET /ip HTTP/1.1” 503 323 “-” “curl/7.21.4 (universal-apple-darwin11.0) libcurl/ 7.21.4 OpenSSL/0.9.8r zlib/1.2.5”
185.12.15.92 - - [23/Nov/2014:03:33:59 -0500] “GET /ip HTTP/1.1” 503 323 “-” “curl/7.30.0”
80.77.87.241 - - [23/Nov/2014:03:34:01 -0500] “GET / HTTP/1.1” 200 19606 “-” “curl/7.19.7 (i386-redhat-linux-gnu) libcurl/7.19 .7 NSS/3.15.3 zlib/1.2.3 libidn/1.18 libssh2/1.4.2”
37.139.8.235 - - [23/Nov/2014:03:34:01 -0500] “GET / HTTP/1.1” 200 7390 “-” “curl/7.19.7 (i386-redhat-linux-gnu) libcurl/7.19 .7 NSS/3.15.3 zlib/1.2.3 libidn/1.18 libssh2/1.4.2”
185.12.15.74 - - [23/Nov/2014:03:34:02 -0500] “GET /ip HTTP/1.1” 503 323 “-” “curl/7.30.0”
185.12.15.89 - - [23/Nov/2014:03:34:03 -0500] “GET /ip HTTP/1.1” 503 323 “-” “curl/7.30.0”
185.12.15.93 - - [23/Nov/2014:03:34:07 -0500] “GET /ip HTTP/1.1” 503 323 “-” “curl/7.30.0”
54.243.188.61 - - [23/Nov/2014:03:34:08 -0500] “GET /ip HTTP/1.1” 503 323 “-” “check_http/v1.4.16 (nagios-plugins 1.4.16)”
198.58.103.36 – – [23/Nov/2014:03:34:36 -0500] “GET /feed/ HTTP/1.1” 304 – “-” “Superfeedr bot/2.0 http://superfeedr.com – 制作您的提要实时:取得联系”
46.113.110.244 - - [23/Nov/2014:03:34:41 -0500] “GET /smallpic.jpg HTTP/1.1” 200 7167 “http://www.inoreader.com/folder/Linux” “Mozilla/ 5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.62 Safari/537.36”
5.45.179.103 – – [23/Nov/2014:03:34:50 -0500] “GET / HTTP/1.1” 200 7396 “-” “Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.4 (KHTML, 像Gecko) Chrome/98 Safari/537.4 (StatusCake)”
87.255.53.44 - - [23/Nov/2014:03:34:53 -0500] “GET /ip HTTP/1.1” 503 323 “-” “curl/7.19.7 (universal-apple-darwin10.0) libcurl/ 7.19.7 OpenSSL/0.9.8r zlib/1.2.3”
87.255.53.45 - - [23/Nov/2014:03:34:54 -0500] “GET /ip HTTP/1.1” 503 323 “-” “curl/7.19.7 (universal-apple-darwin10.0) libcurl/ 7.19.7 OpenSSL/0.9.8r zlib/1.2.3”
208.52.180.23 - - [23/Nov/2014:03:34:58 -0500] “GET /ip HTTP/1.1” 503 323 “-” “curl/7.30.0”
216.126.44.86 - - [23/Nov/2014:03:34:58 -0500] “GET /ip HTTP/1.1” 503 323 “-” “curl/7.37.1”
185.44.128.160 - - [23/Nov/2014:03:34:58 -0500] “GET /ip HTTP/1.1” 503 323 “-” “curl/7.21.4 (universal-apple-darwin11.0) libcurl/ 7.21.4 OpenSSL/0.9.8z zlib/1.2.5”
208.52.180.23 - - [23/Nov/2014:03:34:58 -0500] “GET /ip HTTP/1.1” 503 323 “-” “Python-urllib/2.7”
208.52.180.116 - - [23/Nov/2014:03:34:58 -0500] “GET /ip HTTP/1.1” 503 323 “-” “curl/7.24.0 (x86_64-apple-darwin12.0) libcurl/ 7.24.0 OpenSSL/0.9.8y zlib/1.2.5”
216.126.44.86 - - [23/Nov/2014:03:34:58 -0500] “GET /ip HTTP/1.1” 503 323 “-” “Python-urllib/2.7”
208.52.180.116 - - [23/Nov/2014:03:34:58 -0500] “GET /ip HTTP/1.1” 503 323 “-” “Python-urllib/2.7”
185.12.15.90 - - [23/Nov/2014:03:34:59 -0500] “GET /ip HTTP/1.1” 503 323 “-” “curl/7.30.0”
208.52.145.6 - - [23/Nov/2014:03:34:59 -0500] “GET /ip HTTP/1.1” 503 323 “-” “curl/7.30.0”
185.12.15.92 - - [23/Nov/2014:03:34:59 -0500] “GET /ip HTTP/1.1” 503 323 “-” “curl/7.30.0”
185.12.15.91 - - [23/Nov/2014:03:34:59 -0500] “GET /ip HTTP/1.1” 503 323 “-” “curl/7.30.0”
208.52.180.115 - - [23/Nov/2014:03:34:59 -0500] “GET /ip HTTP/1.1” 503 323 “-” “curl/7.24.0 (x86_64-apple-darwin12.0) libcurl/ 7.24.0 OpenSSL/0.9.8y zlib/1.2.5”
185.12.15.78 - - [23/Nov/2014:03:34:59 -0500] “GET /ip HTTP/1.1” 503 323 “-” “curl/7.30.0”
208.52.180.115 - - [23/Nov/2014:03:34:59 -0500] “GET /ip HTTP/1.1” 503 323 “-” “Python-urllib/2.7”
185.12.15.80 - - [23/Nov/2014:03:34:59 -0500] “GET /ip HTTP/1.1” 503 323 “-” “curl/7.30.0”
185.12.15.94 - - [23/Nov/2014:03:34:59 -0500] “GET /ip HTTP/1.1” 503 323 “-” “curl/7.30.0”
185.12.15.76 - - [23/Nov/2014:03:34:59 -0500] “GET /ip HTTP/1.1” 503 323 “-” “curl/7.30.0”
185.12.15.72 - - [23/Nov/2014:03:34:59 -0500] “GET /ip HTTP/1.1” 503 323 “-” “curl/7.30.0”
87.255.53.54 - - [23/Nov/2014:03:34:59 -0500] “GET /ip HTTP/1.1” 503 323 “-” “curl/7.21.4 (universal-apple-darwin11.0) libcurl/ 7.21.4 OpenSSL/0.9.8r zlib/1.2.5”
185.12.15.74 - - [23/Nov/2014:03:35:01 -0500] “GET /ip HTTP/1.1” 503 323 “-” “curl/7.30.0”
80.77.87.241 - - [23/Nov/2014:03:35:01 -0500] “GET / HTTP/1.1” 200 7452 “-” “curl/7.19.7 (i386-redhat-linux-gnu) libcurl/7.19 .7 NSS/3.15.3 zlib/1.2.3 libidn/1.18 libssh2/1.4.2”
37.139.8.235 - - [23/Nov/2014:03:35:01 -0500] “GET / HTTP/1.1” 200 19606 “-” “curl/7.19.7 (i386-redhat-linux-gnu) libcurl/7.19 .7 NSS/3.15.3 zlib/1.2.3 libidn/1.18 libssh2/1.4.2”
185.12.15.89 - - [23/Nov/2014:03:35:02 -0500] “GET /ip HTTP/1.1” 503 323 “-” “curl/7.30.0”
185.12.15.93 - - [23/Nov/2014:03:35:07 -0500] “GET /ip HTTP/1.1” 503 323 “-” “curl/7.30.0”
54.243.188.61 - - [23/Nov/2014:03:35:08 -0500] “GET /ip HTTP/1.1” 503 323 “-” “check_http/v1.4.16 (nagios-plugins 1.4.16)”
133.9.84.100 - - [23/Nov/2014:03:35:47 -0500] “GET /2014/08/flock-2014-prague-day-2/#content HTTP/1.1” 404 10338 “-” “Mozzila /5.0(兼容;Sonic/1.0;http://www.yama.info.waseda.ac.jp/~crawler/info.html)”
87.255.53.44 - - [23/Nov/2014:03:35:52 -0500] “GET /ip HTTP/1.1” 503 323 “-” “curl/7.19.7 (universal-apple-darwin10.0) libcurl/ 7.19.7 OpenSSL/0.9.8r zlib/1.2.3”
87.255.53.45 - - [23/Nov/2014:03:35:54 -0500] “GET /ip HTTP/1.1” 503 323 “-” “curl/7.19.7 (universal-apple-darwin10.0) libcurl/ 7.19.7 OpenSSL/0.9.8r zlib/1.2.3”
185.12.15.78 - - [23/Nov/2014:03:35:58 -0500] “GET /ip HTTP/1.1” 503 323 “-” “curl/7.30.0”
185.12.15.94 - - [23/Nov/2014:03:35:58 -0500] “GET /ip HTTP/1.1” 503 323 “-” “curl/7.30.0”
185.12.15.76 - - [23/Nov/2014:03:35:58 -0500] “GET /ip HTTP/1.1” 503 323 “-” “curl/7.30.0”
208.52.145.6 - - [23/Nov/2014:03:35:58 -0500] “GET /ip HTTP/1.1” 503 323 “-” “curl/7.30.0”
208.52.180.23 - - [23/Nov/2014:03:35:58 -0500] “GET /ip HTTP/1.1” 503 323 “-” “curl/7.30.0”
208.52.180.116 - - [23/Nov/2014:03:35:58 -0500] “GET /ip HTTP/1.1” 503 323 “-” “curl/7.24.0 (x86_64-apple-darwin12.0) libcurl/ 7.24.0 OpenSSL/0.9.8y zlib/1.2.5”
216.126.44.86 - - [23/Nov/2014:03:35:58 -0500] “GET /ip HTTP/1.1” 503 323 “-” “curl/7.37.1”
185.44.128.160 - - [23/Nov/2014:03:35:59 -0500] “GET /ip HTTP/1.1” 503 323 “-” “curl/7.21.4 (universal-apple-darwin11.0) libcurl/ 7.21.4 OpenSSL/0.9.8z zlib/1.2.5”
185.12.15.72 - - [23/Nov/2014:03:35:59 -0500] “GET /ip HTTP/1.1” 503 323 “-” “curl/7.30.0”
87.255.53.54 - - [23/Nov/2014:03:35:59 -0500] “GET /ip HTTP/1.1” 503 323 “-” “curl/7.21.4 (universal-apple-darwin11.0) libcurl/ 7.21.4 OpenSSL/0.9.8r zlib/1.2.5”
185.12.15.90 - - [23/Nov/2014:03:35:59 -0500] “GET /ip HTTP/1.1” 503 323 “-” “curl/7.30.0”
185.12.15.92 - - [23/Nov/2014:03:35:59 -0500] “GET /ip HTTP/1.1” 503 323 “-” “curl/7.30.0”
185.12.15.91 - - [23/Nov/2014:03:35:59 -0500] “GET /ip HTTP/1.1” 503 323 “-” “curl/7.30.0”
208.52.180.115 - - [23/Nov/2014:03:35:59 -0500] “GET /ip HTTP/1.1” 503 323 “-” “curl/7.24.0 (x86_64-apple-darwin12.0) libcurl/ 7.24.0 OpenSSL/0.9.8y zlib/1.2.5”
185.12.15.80 - - [23/Nov/2014:03:35:59 -0500] “GET /ip HTTP/1.1” 503 323 “-” “curl/7.30.0”
37.139.8.235 - - [23/Nov/2014:03:36:01 -0500] “GET / HTTP/1.1” 200 7428 “-” “curl/7.19.7 (i386-redhat-linux-gnu) libcurl/7.19 .7 NSS/3.15.3 zlib/1.2.3 libidn/1.18 libssh2/1.4.2”
185.12.15.74 - - [23/Nov/2014:03:36:01 -0500] “GET /ip HTTP/1.1” 503 323 “-” “curl/7.30.0”
80.77.87.241 - - [23/Nov/2014:03:36:01 -0500] “GET / HTTP/1.1” 200 19606 “-” “curl/7.19.7 (i386-redhat-linux-gnu) libcurl/7.19 .7 NSS/3.15.3 zlib/1.2.3 libidn/1.18 libssh2/1.4.2”
185.12.15.89 - - [23/Nov/2014:03:36:03 -0500] “GET /ip HTTP/1.1” 503 323 “-” “curl/7.30.0”
185.12.15.93 - - [23/Nov/2014:03:36:07 -0500] “GET /ip HTTP/1.1” 503 323 “-” “curl/7.30.0”
54.243.188.61 - - [23/Nov/2014:03:36:08 -0500] “GET /ip HTTP/1.1” 503 323 “-” “check_http/v1.4.16 (nagios-plugins 1.4.16)”
88.78.165.55 – – [23/Nov/2014:03:36:46 -0500] “GET /smallpic.jpg HTTP/1.1” 200 7167 “http://planet.fedoraproject.org/” “Mozilla/5.0 (iPad ; CPU OS 8_1_1 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Version/8.0 Mobile/12B435 Safari/600.1.4”
87.255.53.44 – – [23/Nov/2014:03:36:53 -0500] “GET /ip HTTP/1.1” 503 323 “-” “curl/7.19.7 (universal-apple-darwin10.0) libcurl/ 7.19.7 OpenSSL/0.9.8r zlib/1.2.3”
87.255.53.45 - - [23/Nov/2014:03:36:54 -0500] “GET /ip HTTP/1.1” 503 323 “-” “curl/7.19.7 (universal-apple-darwin10.0) libcurl/ 7.19.7 OpenSSL/0.9.8r zlib/1.2.3”
185.44.128.160 - - [23/Nov/2014:03:36:58 -0500] “GET /ip HTTP/1.1” 503 323 “-” “curl/7.21.4 (universal-apple-darwin11.0) libcurl/ 7.21.4 OpenSSL/0.9.8z zlib/1.2.5”
208.52.180.115 - - [23/Nov/2014:03:36:58 -0500] “GET /ip HTTP/1.1” 503 323 “-” “curl/7.24.0 (x86_64-apple-darwin12.0) libcurl/ 7.24.0 OpenSSL/0.9.8y zlib/1.2.5”
208.52.145.6 - - [23/Nov/2014:03:36:58 -0500] “GET /ip HTTP/1.1” 503 323 “-” “curl/7.30.0”
185.12.15.90 - - [23/Nov/2014:03:36:58 -0500] “GET /ip HTTP/1.1” 503 323 “-” “curl/7.30.0”
185.12.15.92 - - [23/Nov/2014:03:36:59 -0500] “GET /ip HTTP/1.1” 503 323 “-” “curl/7.30.0”
208.52.180.23 - - [23/Nov/2014:03:36:59 -0500] “GET /ip HTTP/1.1” 503 323 “-” “curl/7.30.0”
185.12.15.78 - - [23/Nov/2014:03:36:59 -0500] “GET /ip HTTP/1.1” 503 323 “-” “curl/7.30.0”
185.12.15.91 - - [23/Nov/2014:03:36:59 -0500] “GET /ip HTTP/1.1” 503 323 “-” “curl/7.30.0”
216.126.44.86 - - [23/Nov/2014:03:36:59 -0500] “GET /ip HTTP/1.1” 503 323 “-” “curl/7.37.1”
185.12.15.94 - - [23/Nov/2014:03:36:59 -0500] “GET /ip HTTP/1.1” 503 323 “-” “curl/7.30.0”
185.12.15.76 - - [23/Nov/2014:03:36:59 -0500] “GET /ip HTTP/1.1” 503 323 “-” “curl/7.30.0”
208.52.180.116 - - [23/Nov/2014:03:36:59 -0500] “GET /ip HTTP/1.1” 503 323 “-” “curl/7.24.0 (x86_64-apple-darwin12.0) libcurl/ 7.24.0 OpenSSL/0.9.8y zlib/1.2.5”
185.12.15.80 - - [23/Nov/2014:03:36:59 -0500] “GET /ip HTTP/1.1” 503 323 “-” “curl/7.30.0”
185.12.15.72 - - [23/Nov/2014:03:36:59 -0500] “GET /ip HTTP/1.1” 503 323 “-” “curl/7.30.0”
87.255.53.54 - - [23/Nov/2014:03:36:59 -0500] “GET /ip HTTP/1.1” 503 323 “-” “curl/7.21.4 (universal-apple-darwin11.0) libcurl/ 7.21.4 OpenSSL/0.9.8r zlib/1.2.5”
185.12.15.74 - - [23/Nov/2014:03:37:01 -0500] “GET /ip HTTP/1.1” 503 323 “-” “curl/7.30.0”
80.77.87.241 - - [23/Nov/2014:03:37:01 -0500] “GET / HTTP/1.1” 200 7368 “-” “curl/7.19.7 (i386-redhat-linux-gnu) libcurl/7.19 .7 NSS/3.15.3 zlib/1.2.3 libidn/1.18 libssh2/1.4.2”
EOF
示例输出(明文链接)
503 88
200 10
404 1
304 1
解释
日志文件将作为标准输入提供。您需要通过 STDOUT 写入输出。
输入将由通过 STDIN 逐行给出的一些 Web 服务器日志行组成。输入结束将由 EOF 给出。在输出中,在每行中打印出现的 HTTP 代码以及它们出现的次数(用空格分隔两个值)。输出应按出现的降序排序。
时间限制:每个输入文件 5 秒。
内存限制:256 MB
源限制:1024 KB
评分方案:如果任何测试用例通过,则给予评分。
允许的语言:C、C++、Clojure、C#、Go、Haskell、 Java、JavaScript、Objective-C、Perl、 PHP、 Python、Ruby