SHEIN Java开发笔试4.21

单选15道,多选8道(好像),两道编程题 选择题大部分都是基础八股,哈希表问的比较多,单选最后一道题问了Spring的注解(具体内容忘了,因为不会所以乱选的)

然后是编程题

  1. SQL题,从某乎问答中找出11月份的平均回答量,结果保留两位小数
SELECT answer_data, ROUND(COUNT(issue_id) / COUNT(DISTINCT author_id), 2)
FROM answer_table 
WHERE MONTH(answer_date) = 11
GROUP BY answer_date
  1. 简单的最长不重复子串,要求得到所有的最长不重复子串。坑的是语言只能选Java、Go、Ruby

Java:

public static String[] longestSubstring(String input) {
    ArrayList<String> res = new ArrayList<>();
    if (input == null) return null;

    Map<Character, Integer> hash = new HashMap<>();
    int l = 0, r = 0, max_len = 0;
    while (r < input.length()) {
        Character c = input.charAt(r);
        if (hash.containsKey(c) && hash.get(c) >= l)
          l = hash.get(c) + 1;
        hash.put(c, r);
        int len = r - l + 1;
        if (len > max_len) {
          max_len = len;
          res.clear();
          res.add(input.substring(l, r+1));
        } else if (len == max_len)
          res.add(input.substring(l, r+1));
        ++r;
    }

    return (String[]) res.toArray();
}

Go:

func longestSubstring(input string) []string {
    var res []string
    if input == "" {
        return nil
    }

    hash := make(map[rune]int)
    l, r, maxLen := 0, 0, 0
    for r < len(input) {
        c := rune(input[r])
        if _, ok := hash[c]; ok && hash[c] >= l {
            l = hash[c] + 1
        }
        hash[c] = r
        len := r - l + 1
        if len > maxLen {
            maxLen = len
            res = []string{input[l : r+1]}
        } else if len == maxLen {
            res = append(res, input[l:r+1])
        }
        r++
    }

    return res
}

Ruby:

def longest_substring(input)
  res = []
  return nil if input.nil?

  hash = {}
  l = 0
  r = 0
  max_len = 0
  while r < input.length
    c = input[r]
    if hash.key?(c) && hash[c] >= l
      l = hash[c] + 1
    end
    hash[c] = r
    len = r - l + 1
    if len > max_len
      max_len = len
      res.clear
      res.push(input[l..r])
    elsif len == max_len
      res.push(input[l..r])
    end
    r += 1
  end

  return res.to_a
end
#软件开发2023笔面经#
全部评论
sql的 我这样写为啥查不出来SELECT answer_date, ROUND(COUNT(DISTINCT issue_id) / COUNT(DISTINCT author_id), 2) AS per_num FROM answer_tb WHERE MONTH(answer_date) = 11 GROUP BY answer_date ORDER BY answer_date ASC;
1 回复
分享
发布于 2023-04-26 13:03 广东
笔试时间是多久
点赞 回复
分享
发布于 2023-04-21 18:03 四川
联易融
校招火热招聘中
官网直投
有后续了吗
点赞 回复
分享
发布于 2023-04-21 18:06 天津

相关推荐

9 32 评论
分享
牛客网
牛客企业服务