本文主要是介绍A string s is LUCKY if and only if the number of different characters in s is a fibonacci number. Gi,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
题目描述A string s is LUCKY if and only if the number of different characters in s is a fibonacci number. Given a string consisting of only lower case letters , output all its lucky non-empty substrings in lexicographical order. Same substrings should be printed once.
输入描述:
a string consisting no more than 100 lower case letters.输出描述:
output the lucky substrings in lexicographical order.one per line. Same substrings should be printed once.输入例子:
aabcd输出例子:
a
aa
aab
aabc
ab
abc
b
bc
bcd
c
cd
d
一晚上就做了这一道题,必须纪念下!
才知道TreeSet是有序的,HashSet是无序的,要是把HashSet排序很麻烦。。。
import java.util.ArrayList;
import java.util.Date;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;public class Main {public static void main(String[] args) {Main main = new Main();// main.findLuc
这篇关于A string s is LUCKY if and only if the number of different characters in s is a fibonacci number. Gi的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!