• 趋势科技面试


    2019/4/5 1:36


    面试官随机提问项目中敏感词过滤服务,如果你是测试人员的话, 你会对于这个过滤服务生成怎样的测试用例;
    当时想到的是:“

    1. 对东亚文词库:
    2. 对颜表情,
    3. 对敏感词库的部分特殊字符修改;(包括对敏感词库中字符串加空格,敏感词反写)

    现在突然想到对于测试用例的书写,不必要每次都想出来新的测试用例,,其实可以一组测试用例用全排列算法,实现生成所有的测试案例的orz

    自己当时一心卡在测试用例,怎么来优化算法通过case,有些没有get到面试官问如何实现测试案例这个点;

     1 public class RecursionPermutation {
     2 
     3 public static void permutate(String input){
     4 if(input == null)
     5 throw new IllegalArgumentException();
     6 char[] data = input.toCharArray();
     7 permutate(data, 0);
     8 }
     9 
    10 public static void permutate(char[] data, int begin){
    11 int length = data.length;
    12 if(begin == length)
    13 System.out.println(data);
    14 for(int i = begin ; i < length; i++)
    15 {
    16 if(isUnique(data, begin, i)){
    17 swap(data, begin, i);
    18 permutate(data, begin + 1);
    19 swap(data, begin, i);
    20 } 
    21 }
    22 }
    23 
    24 private static boolean isUnique(char[] data, int begin, int end){
    25 for(int i = begin; i < end; i++)
    26 if(data[i] == data[end])
    27 return false;
    28 return true;
    29 }
    30 
    31 private static void swap(char[] data, int left, int right) {
    32 char temp = data[left];
    33 data[left] = data[right];
    34 data[right] = temp;
    35 }
    36 
    37 
    38 public static void main(String... args){
    39 RecursionPermutation.permutate("aac");
    40 }
    41 
    42 }
    递归实现全排列

    全排列的一些博客:

    https://blog.csdn.net/summerxiachen/article/details/60579623

    https://www.cnblogs.com/zhouthanos/p/3807495.html

  • 相关阅读:
    HDU-统计难题
    POJ-A Simple Problem with Integers
    HDU-I Hate It
    个人站立会议06
    个人站立会议05
    个人站立会议04
    易校小程序典型用户需求分析
    个人站立会议03
    个人第二次晚间站立总结会议
    个人站立会议02
  • 原文地址:https://www.cnblogs.com/liguo-wang/p/10657803.html
Copyright © 2020-2023  润新知