SPOJ Problem Set (classical) 694. Distinct Substrings Problem code: DISUBSTR Given a string, we need to find the total number of its distinct substrings. Input T- number of test cases. T<=20; Each test case consists of one string, whose length is <=…
最长回文 Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 31611    Accepted Submission(s): 11618 Problem Description 给出一个只由小写英文字符a,b,c...y,z组成的字符串S,求S中最长回文串的长度.回文就是正反读都是一样的字符串,如aba, abba等   Input 输入有…
package cn.itcast.p1.map.test; import java.util.Iterator; import java.util.Map; import java.util.TreeMap; public class TestMap { /** * 练习: * "fdgavcbsacdfs+++AA&&BBB" 获取该字符串中,每一个字母出现的次数. * 要求打印结果是:a(2)b(1)...; * 思路: * 对于结果的分析发现,字母和次数之间存在…
方法1:先对数组进行排序,然后遍历前K个数,此时时间复杂度为O(nlgn); 方法2:维护一个容量为K的最大堆(<算法导论>第6章),然后从第K+1个元素开始遍历,和堆中的最大元素比较,如果大于最大元素则忽略,如果小于最大元素则将次元素送入堆中,并将堆的最大元素删除,调整堆的结构; 方法3:使用快速排序的原理,选择出数组中第K大的元素,select(a[], k, low, high) 选取数组中a[high]为基准,将数组分割为A1和A2,A1中的元素都比a[high]小,A[2]中的元素都…
Sample Input abcdaaaaababab.Sample Output 1 //1个abcd4 //4个a3 //3个ab #include<stdio.h> #include<iostream> #include<string.h> #include<algorithm> using namespace std; ; char T[MAXN]; int next[MAXN]; int n; void getNext() { int j,k; j…
给出代码 #include <stdio.h> #include <unistd.h> #include <iostream> #include <memory.h> #include <string.h> int main() { typedef int data_type; data_type a[] = {1,4,6,7,7,8,4,9,1,7,6,4,1,2,0,0}; const char* hint = "The origi…
主要掌握String中的方法 char[] toCharArray()           将此字符串转换为一个新的字符数组. int indexOf(String str)           返回指定子字符串在此字符串中第一次出现处的索引. int lastIndexOf(String str)           返回指定子字符串在此字符串中最右边出现处的索引 集合List和set的区别 List中可以出现重复的元素,Set中不能出现重复的元素 集合遍历: List遍历 Iterator<…
功能:找出来一个字符串中最长不重复子串 def find_longest_no_repeat_substr(one_str): #定义一个列表用于存储非重复字符子串 res_list=[] #获得字符串长度 length=len(one_str) for i in range(length): tmp=one_str[i] for j in range(i+1, length): #用取到的字符与tmp中的字符相匹配,匹配不成功tmp字符继续增加,匹配成功直接跳出循环加入到res_list列表中…
题目:写一个函数,求一个字符串的长度,在main函数中输入字符串,并输出其长度. public class _038PrintLength { public static void main(String[] args) { printLength(); } private static void printLength() { Scanner scanner = new Scanner(System.in); System.out.println("请输入一个字符串 :"); Str…
import java.util.Scanner; /** * [程序38] * * 题目:写一个函数,求一个字符串的长度,在main函数中输入字符串,并输出其长度. * * @author James * */ public class 第三十八题统计字符串的长度 { public static void main(String[] args) { System.out.println("请输入一个字符串"); Scanner in = new Scanner(System.in);…