注册一亩三分地论坛,查看更多干货!
您需要 登录 才可以下载或查看附件。没有帐号?注册账号 
x
本帖最后由 小山1213 于 2022-3-1 21:38 编辑
贡献一个被惨虐的VO吧,两轮coding都是从他们工作中实际出发的问题,对这类问题确实准备很不充分,需要大量的沟通,明确需求。
1. 给一个dataset,实现一个function能以x,y,sum的形式aggregate出结果。2. 实现类JSON parser的function,我没完全实现,基本就是需要自己定义需要的类,参数,然后完成token parse。把题目要求放在这里。- /*
- Your previous Plain Text content is preserved below:
- We'd like to parse a JSON string into a data structure that we can inspect and modify. Well known examples of this include Javascript's JSON.parse, Python's json module, or Java's Jackson library.
- Traditionally there are two modules in this process: lexing and parsing. The lexer transforms the input string into a list of tokens, and the parser consumes the tokens to produce a data structure (ie class, object, AST) representing the input string.
- For this problem, we'll implement the parser component for JSON. That is, given a list of tokens that represent a valid JSON object, we'd like to produce an in-memory representation that we can inspect and modify.
- Here's a basic JSON object, followed by the list of tokens representing it.
- {
- "a": 10,
- "b": "foo",
- }
- example_json_tokens = [
- { 'type': 'start-object' },
- { 'type': 'field-name', 'val': 'a' },
- { 'type': 'number', 'val': 10 },
- { 'type': 'field-name', 'val': 'b' },
- { 'type': 'string', 'val': 'foo' },
- { 'type': 'end-object' },
- ]
- {
- "a": 10,
- "b": "foo",
- "c": [null, true],
- "d": { "e": { "f": "nested" }}
- }
- - { type: 'start-object' }
- - { type: 'field-name', val: 'a' }
- - { type: 'number', val: 10 }
- - { type: 'field-name', val: 'b' }
- - { type: 'string', val: 'foo" }
- - { type: 'field-name', val: 'c' }
- - { type: 'start-array' }
- - { type: 'null' }
- - { type: 'boolean', val: true}
- ...
- type Token =
- { type: 'start-object' } // {
- { type: 'end-object' } // }
- { type: 'start-array' } // [
- { type: 'end-array' } // ]
- { type: 'field-name', val: string } // the key in a JSON map
- { type: 'string', val: string } // a string literal
- { type: 'number', val: number } // a number literal
- { type: 'boolean', val: boolean } // a boolean literal
- { type: 'null' } // a null literal
- */
复制代码 3. sys design,讨论hasd aggregate the sold count
// e.g. select storeid as x, and color as y, return something like
// storeid, date, sold-count
// 1 1-2-2022 60
// 2 2-2-2022 100
// 3 3-2-2022 30 |