
算法
文章平均质量分 58
StephenZou14
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
字符串变换最小问题
题目: 给出两个字串A,B。将A字串转化为B字串,转化一共有两种方式:删除连续的n个字符,一次操作费用为2。增加连续的n个字符(增加的字符是什么由你决定),一次操作费用为n+2。求把A变为B最小费用。输入: 第一行输入一个正整数T(1 <= T <= 10),表示有T组测试数据。对于每组测试数据:两行字符串A, B(字符串长度不超过2000,字符仅包含小写字母)输出: 对于每组测试数据原创 2016-09-22 21:24:27 · 3413 阅读 · 0 评论 -
Contains Duplicate II
Given an array of integers and an integer k, find out whether there are two distinct indices i and j in the array such that nums[i] = nums[j] and the absolute difference between i and j is at most k.思想原创 2017-07-16 14:56:30 · 355 阅读 · 0 评论 -
Valid Anagram
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 true. s = “rat”, t = “car”, return false.Note: You may assume the s原创 2017-07-18 22:52:00 · 350 阅读 · 0 评论 -
Skip List
Skip List 是什么我们常用数组和链表来组织数据,对于已排序的数据,数组的查询时间复杂度可以是Θ(lgn)Θ(lgn)(二分查找),插入和删除都是Θ(n)Θ(n)。链表提供了一种更加灵活的组织方式,插入和删除的时间复杂度是Θ(1)Θ(1),查询的时间复杂度是Θ(n)Θ(n)。平衡树是更好的方案,查询、插入、删除的时间复杂度都是Θ(lgn)Θ(lgn),但实现上比较复杂。Skip List作为性转载 2017-10-24 14:20:53 · 656 阅读 · 0 评论 -
Longest Palindromic Substring
Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000.Example:Input: "babad"Output: "bab"Note: "aba" is also a valid answer.Example:Input原创 2016-12-04 12:52:44 · 362 阅读 · 0 评论 -
根据value值对map进行排序
今天在做笔试题的时候发现需要根据value值对map进行排序,通过查资料发现其基本思路是通过讲map中的键值对转化存储到vector中进行排序得到的。 代码如下:#include<iostream>#include<vector>#include<map>#include<string>#include<algorithm>using namespace std;int cmpValue(原创 2016-12-19 09:33:36 · 1212 阅读 · 0 评论