class

Download Class

If you can't read please download the document

Upload: ankit-kashyap

Post on 17-Nov-2015

212 views

Category:

Documents


0 download

DESCRIPTION

no des

TRANSCRIPT

using System;using System.Linq;namespace ConsoleApplication1{ class Program { static void Main(string[] args) { bool done = true; do{ string str = Console.ReadLine(); int N = 0; if (str == "0") { done = false; break; } else { N = Int32.Parse(System.Console.ReadLine().Trim()); int result = 0; int fill = 0; string[] arr = new string[N]; for (int i = 0; i < str.Length; i++) { if (!arr.Contains(str[i].ToString())) { if (fill < N) { int index = Array.IndexOf(arr, ""); if (index < 0) index = Array.IndexOf(arr, null); arr[index] = str[i].ToString(); fill++; } else { if (!str.Substring(0, i).ToLower().Contains(str[i].ToString().ToLower())) result++; } } else { fill--; arr[Array.IndexOf(arr, str[i].ToString())] = ""; } } Console.WriteLine(result); } } while (done); //do // string str = Console.ReadLine(); //} while (Console.ReadLine()!= "0"); // //try //{ // long[] sol = new long[100000000]; // long[] inputs = new long[100000000]; // for (int i = 1; i