D E笔试题

试题:

1.  从一个数组中,输出95分位的数字

2.  在工作过程中,在某一app服务的日志中,可以得到如下的信息:

RemoteIP=10.21.46.22

请求协议:HTTP

请求方式:Post

请求path:/api/v1/comp/listings

请求参数:

variant=default

shipToSite=0

postalCode=10011

Payload: {"id":"383541190088","title":"Sonic Rechargeable Electric Toothbrush Fairywill Timer Waterproof 12 Brush Head”}

基于以上信息,重组HTTP请求(可以在postman或者linux shell)

3.  一个table,里面每行记录表示一个click,column有siteid, clickid, userid,写一个sql获取每个国家点击数量前3的userid

4. 设计一个HTML,含如下内容

1)一行总结,PASS显示绿色,FAIL显示红色

2)一个table, 第一行是header, 第二行是期望结果,第三行是比较结果,与第二行结果不一样的用颜色区分出来。

如下图所示 (数据及内容可以随意)

5. ​​设计一个支持 push ,pop ,top 操作,并能在常数时间内检索到最小元素的栈。

实现 MinStack 类:

MinStack() 初始化堆栈对象。

void push(int val) 将元素val推入堆栈。

void pop() 删除堆栈顶部的元素。

int top() 获取堆栈顶部的元素。

int getMin() 获取堆栈中的最小元素。

6. 找出两个字符串的最长公共子串:如 abcdef 与 abecdef,最长为cdef.

7. 浏览器打开一网址到看到页面都经历了哪些过程

1.

import numpy as np

    arr = np.array([1,2,3,4])

    np.median(arr)

    np.percentile(arr,95)

2.

100%

取消上传

3.

SELECT

    siteid,

    userid,

    ct 

FROM

    (

    SELECT

        siteid,

        userid,

        ct,

        rank() over ( PARTITION BY siteid ORDER BY ct DESC ) AS rk 

    FROM

        ( SELECT siteid, userid, COUNT(*) AS ct FROM TABLENAME GROUP BY siteid, userid ) A 

    ) B 

WHERE

    rk <= 3;

    

4.

<template>

  <div v-for="item in compareList" :key="item.index">

       <p v-if="item.result == 'PASS'" style="color:green; fontSize: 16px">Result:<span>{{item.result}}</span></p>

    <p v-if="item.result == 'FAIL'" style="color:red; fontSize: 16px">Result:<span>{{item.result}}</span></p>

    <table border="1" id="table1">

        <thead>

            <tr>

                <th></th>

                <th>age</th>

                <th>color</th>

            </tr>

        </thead>

        <tr>

            <th>Benchmark</th>

            <td>{{Benchmark.age}}</td>

            <td>{{Benchmark.color}}</td>

        </tr>

        <tr v-for="item_compare in item.list" >

            <th>Compare</th>

            <td v-if="item_compare.compare == 'age'" style="color:blue;">{{item_compare.age}}</td>

              <td v-else>{{item_compare.age}}</td>

            <td v-if="item_compare.compare == 'color'" style="color:red;">{{item_compare.color}}</td>

              <td>{{item_compare.color}}</td>

        </tr>

    </table>

  </div>

</template>

<script>

export default {

  data() {

    return {

      Benchmark:{

        age:10,

        color:"red"

      },

      compareList :[

        {

          result:"PASS",

          index:0,

          list:[

            {

              age:10,

              color:"red",

              compare:""

            },

            {

              age:10,

              color:"red",

              compare:""

            }

          ]

          },

       {

        result:"PASS",

        index:1,

        list:[

          {

            age:10,

            color:"red",

            compare:""

          },

          {

            age:20,

            color:"red",

            compare:""

          },

          {

            age:10,

            color:"red",

            compare:""

          }

        ]

      }

      ]

    };

  },

  methods: {},

  beforeMount() {

    for (let item of this.compareList){

        for (let key of item.list){

        if (key.age != this.Benchmark.age || key.color != this.Benchmark.color ){

          item.result = "FAIL"

          if (key.age != this.Benchmark.age){

            key.compare = "age"

          }

          if (key.color != this.Benchmark.color){

            key.compare = "color"

          }

          // break

        }

        }

    }

  },

  mounted() {}

};

</script>

<style></style>

5.

class MinStack(object):

    def __init__(self):

        self.stack = []  # 存放所有元素

        self.minStack = []  

    def push(self, x):

        self.stack.append(x)

        if not self.minStack or self.minStack[-1] >= x:

            self.minStack.append(x)

    def pop(self):  # 移除栈顶元素时,判断是否移除栈中最小值

        if self.minStack[-1] == self.stack[-1]:

            del self.minStack[-1]

        self.stack.pop()

    def top(self):   #获取栈顶元素

        return self.stack[-1]

    def getMin(self): #获取栈中的最小值

        return self.minStack[-1]

    def all(self):  #列表栈中所有的元素

        return self.stack[:]

6.

def getMaxSub(str1,str2):

    n1=len(str1)

    n2=len(str2)

    s=[] #公共子串

    maxs=0 #最长公共子串的长度

    maxI=0 #记录最长公共子串最后一个字符的位置

    list1=list(str1)

    list2=list(str2)

    M=[([None]*(n1+1)) for i in range(n2+1)] #(n1+1)*(n2+1)维空矩阵,记录公共子串

    for i in range(n1+1):

        M[i][0]=0

    for j in range(n2):

        M[0][j]=0 

    for i in range(n1):

        for j in range(n2):

            if list1[i]==list2[j]:

                M[i+1][j+1]=M[i][j]+1

                if M[i+1][j+1]>maxs:

                    maxs=M[i+1][j+1]

                    maxI=i+1

            else:

                M[i+1][j+1]=0                

    for i in range(maxI-maxs,maxI):

        s.append(list1[i])

    result=''.join(s)

    print(result)

if __name__ == '__main__':

    str1='abccade'

    str2='dgcadde'

    getMaxSub(str1,str2) 

7.

1.对网址进行DNS域名解析,得到对应的ip地址;

2.根据这个ip,找到对应的服务器,建立TCP连接(三次握手);

(TCP是比http更底层的传输层协议)

3.TCP连接之后,发起http请求;

4.http响应返回回来html代码,浏览器接收到html代码;

5.浏览器解析html代码,并请求html代码中的一些资源(js文件、图片、css文件等)

6.浏览器渲染html;

7.服务器关闭连接  tcp、http连接

<template>

  <div v-for="item in compareList" :key="item.index">

       <p v-if="item.result == 'PASS'" style="color:green; fontSize: 16px">Result:<span>{{item.result}}</span></p>

    <p v-if="item.result == 'FAIL'" style="color:red; fontSize: 16px">Result:<span>{{item.result}}</span></p>

    <table border="1" id="table1">

        <thead>

            <tr>

                <th></th>

                <th>age</th>

                <th>color</th>

            </tr>

        </thead>

        <tr>

            <th>Benchmark</th>

            <td>{{Benchmark.age}}</td>

            <td>{{Benchmark.color}}</td>

        </tr>

        <tr v-for="item_compare in item.list" >

            <th>Compare</th>

            <td v-if="item_compare.compare == 'age'" style="color:blue;">{{item_compare.age}}</td>

              <td v-else>{{item_compare.age}}</td>

            <td v-if="item_compare.compare == 'color'" style="color:red;">{{item_compare.color}}</td>

              <td>{{item_compare.color}}</td>

        </tr>

    </table>

  </div>

</template>

<script>

export default {

  data() {

    return {

      Benchmark:{

        age:10,

        color:"red"

      },

      compareList :[

        {

          result:"PASS",

          index:0,

          list:[

            {

              age:10,

              color:"red",

              compare:""

            },

            {

              age:10,

              color:"red",

              compare:""

            }

          ]

          },

       {

        result:"PASS",

        index:1,

        list:[

          {

            age:10,

            color:"red",

            compare:""

          },

          {

            age:20,

            color:"red",

            compare:""

          },

          {

            age:10,

            color:"red",

            compare:""

          }

        ]

      }

      ]

    };

  },

  methods: {},

  beforeMount() {

    for (let item of this.compareList){

        for (let key of item.list){

        if (key.age != this.Benchmark.age || key.color != this.Benchmark.color ){

          item.result = "FAIL"

          if (key.age != this.Benchmark.age){

            key.compare = "age"

          }

          if (key.color != this.Benchmark.color){

            key.compare = "color"

          }

          // break

        }

        }

    }

  },

  mounted() {}

};

</script>

<style></style>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值