文件: root - text - article - 2019 - 12 - longest-substring-with-k-distinct-characters.txt.txt
标签: 每日算法题, Longest Substring With K Distinct Characters算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | 英文 | 主页 | 类别: 计算机科学 | 534 次阅读, 24053 次搜索 | 94 个单词
| 浏览 | 博客存档
标签: 每日算法题, Longest Substring With K Distinct Characters算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | 英文 | 主页 | 类别: 计算机科学 | 534 次阅读, 24053 次搜索 | 94 个单词
| 浏览 | 博客存档
Hi, here's your problem today. This problem was recently asked by Amazon:
You are given a string s, and an integer k. Return the length of the longest substring in s that contains at most k distinct characters.
For instance, given the string:
aabcdefff and k = 3, then the longest substring with 3 distinct characters would be defff. The answer should be 5.
Here's a starting point:
标签: 每日算法题, Longest Substring With K Distinct Characters算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | 英文 | 主页 | 类别: 计算机科学 | 534 次阅读, 24053 次搜索 | 94 个单词 You are given a string s, and an integer k. Return the length of the longest substring in s that contains at most k distinct characters.
For instance, given the string:
aabcdefff and k = 3, then the longest substring with 3 distinct characters would be defff. The answer should be 5.
Here's a starting point:
def longest_substring_with_k_distinct_characters(s, k):
# Fill this in.
print longest_substring_with_k_distinct_characters('aabcdefff', 3)
# 5 (because 'defff' has length 5 with 3 characters)
猜您喜欢...
- Daily Interview Problem: Contiguous Subarray with Maximum Sum
- Delphi Dynamic Array
- Algorithm Interview: No Adjacent Repeating Characters
- Longest Substring Without Repeating Characters
- Compare Version Numbers
- Daily Interview Problem: Largest BST in a Binary Tree
- How to Play WAV music under DOS?
- Daily Interview Problem: Longest Substring With K Distinct Characters
- Daily Interview Puzzle: Ways to Traverse a Grid
- Daily Interview Problem: Group Words that are Anagrams
©2006~2024 牛排过熟 - 0.00686 秒 - 2998.008 KB/s - 32 在线 内存: 494.8 KB
18:54:01 up 13 days, 18:33, 2 users, load average: 0.98, 0.86, 0.73 - 服务器 PHP 版本号: 7.4.33
牛排怎么做才好吃? | <meta name="机器人" content="索引, 跟踪">
18:54:01 up 13 days, 18:33, 2 users, load average: 0.98, 0.86, 0.73 - 服务器 PHP 版本号: 7.4.33
评论 (0)
读写完全 - 一般 - 最小 - 表格 - 所有评论 - 统计
当前页暂时没有评论。