摘要: 解题思路:本题是一道图的题目,但是无向图,给定的输入是图的各个边,题目中给出一个关键信息(Each node has labels in the set {0, 1, ..., edges.length})可知图中没有环,如果是有环的图这个题是无解的。最好的证明方法就是反正法,如果有环的话标号最大 阅读全文
posted @ 2019-11-14 13:48 蓝色地中海 阅读(337) 评论(0) 推荐(0) 编辑
摘要: 这是一道字符的匹配问题,主要的思路就是两个数组各自遍历一边,使用一个unordered_map来记录第一个遍历的数组的信息,遍历第二个数组的时候统计最终的结果。 时间复杂度为O(m + n)。 空间复杂度为O(n) 阅读全文
posted @ 2019-08-16 12:54 蓝色地中海 阅读(89) 评论(0) 推荐(0) 编辑
摘要: 解题思路:因为给定的string已经按序排列,所以这是一个典型的双指针滑动窗口的问题。 设置两个指针。 一个指向开始位置(start),另外一个指针不断的向后滑动 如果滑动指针指向的值与start指针指向的值相同,则继续向后滑动 如果滑动指针指向的值与start指针指向的值不同,则判断group长度 阅读全文
posted @ 2019-08-16 12:50 蓝色地中海 阅读(193) 评论(0) 推荐(0) 编辑
摘要: Problem statement In English, we have a concept called root, which can be followed by some other words to form another longer word - let's call this w 阅读全文
posted @ 2017-07-26 04:37 蓝色地中海 阅读(543) 评论(0) 推荐(0) 编辑
摘要: Problem statement Given a string, your task is to count how many palindromic substrings in this string. The substrings with different start indexes or 阅读全文
posted @ 2017-07-26 03:47 蓝色地中海 阅读(513) 评论(0) 推荐(0) 编辑
摘要: Problem statement Given a collection of intervals, find the minimum number of intervals you need to remove to make the rest of the intervals non-overl 阅读全文
posted @ 2017-07-26 01:47 蓝色地中海 阅读(243) 评论(0) 推荐(0) 编辑
摘要: Problem statement You are given n pairs of numbers. In every pair, the first number is always smaller than the second number. Now, we define a pair (c 阅读全文
posted @ 2017-07-25 05:04 蓝色地中海 阅读(702) 评论(0) 推荐(0) 编辑
摘要: Problem statement The set S originally contains numbers from 1 to n. But unfortunately, due to the data error, one of the numbers in the set got dupli 阅读全文
posted @ 2017-07-24 03:28 蓝色地中海 阅读(210) 评论(0) 推荐(0) 编辑
摘要: Problem statement Given two strings s and t, write a function to determine if t is an anagram of s. For example,s = "anagram", t = "nagaram", return t 阅读全文
posted @ 2017-06-23 08:44 蓝色地中海 阅读(142) 评论(0) 推荐(0) 编辑
摘要: Problem statement Given a string s and a non-empty string p, find all the start indices of p's anagrams in s. Strings consists of lowercase English le 阅读全文
posted @ 2017-06-23 08:32 蓝色地中海 阅读(158) 评论(0) 推荐(0) 编辑