首页 > 其他 > 详细

[LeetCode] Prefix and Suffix Search 前后缀搜索

时间:2018-01-23 00:38:48      阅读:289      评论:0      收藏:0      [点我收藏+]

标签:example   ase   fun   etc   后缀   ffi   turn   exist   ade   

 

Given many words, words[i] has weight i.

Design a class WordFilter that supports one function, WordFilter.f(String prefix, String suffix). It will return the word with given prefix and suffix with maximum weight. If no word exists, return -1.

Examples:

Input:
WordFilter(["apple"])
WordFilter.f("a", "e") // returns 0
WordFilter.f("b", "") // returns -1

Note:

    1. words has length in range [1, 15000].
    2. For each test case, up to words.length queries WordFilter.f may be made.
    3. words[i] has length in range [1, 10].
    4. prefix, suffix have lengths in range [0, 10].
    5. words[i] and prefix, suffix queries consist of lowercase letters only.

 

s

 

[LeetCode] Prefix and Suffix Search 前后缀搜索

标签:example   ase   fun   etc   后缀   ffi   turn   exist   ade   

原文:https://www.cnblogs.com/grandyang/p/8331660.html

(0)
(0)
   
举报
评论 一句话评论(0
0条  
登录后才能评论!
© 2014 bubuko.com 版权所有 鲁ICP备09046678号-4
打开技术之扣,分享程序人生!
             

鲁公网安备 37021202000002号