From: http://bbs.csdn.net/topics/310249367
Super stupid wolf
Question: There is a string array of <string> = "ABC", "BAC", "ACB"... 0.1 million elements, each with a length of 3 to 16 characters.
Only one combination is retained. That is to say, strings with the same content are deleted only for strings with different character combinations.
The result must be calculated within one second.
The following figure shows the input data:
Static void main (string [] ARGs)
{
// 0.1 million strings.
Int totalstr = 10*10000;
List <string> myarr = new list <string> ();
Int totallength = 0;
Char [] input = "a hundred feet high in a dangerous building on a hundred feet higher than a hundred feet from the Yellow River to the current in the white sky, so that the stars do not speak loudly and may be stunned". tochararray ();
Random Rand = new random ();
For (INT I = 0; I <totalstr; I ++) // 0.1 million data records
{
String tempstr = "";
Int templength = Rand. Next (3, 16); // 3 to 16 characters
For (Int J = 0; j <templength; j ++)
{
Tempstr + = input [Rand. Next (0, input. Length)]; // use a-Z for English Testing
}
Totallength + = templength;
Myarr. Add (tempstr );
}
// Test starts
Long begin = system. datetime. Now. ticks;
// Write the program code here. You can write functions or classes to call them here.
........
Long end = system. datetime. Now. ticks;
Console. writeline ("Total" + totalstr/10000 + "pieces of data, total length" + totallength + ", after completion, we need" + system. timespan. fromticks (end-begin ). milliseconds + "millisecond ");
Console. Readline ();
}
Go to: Remove duplicate string combinations