首页 > 其他 > 详细

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

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

 

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 前后缀搜索

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

(1)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!