I have below code, for which I am getting error as Time Limit Exceeded.
But when I am submitting the solution, it gets accepted.
Also, Memory size for the code that I submitted is quite large, and I have checked some other codes with less memory utilization, their code looks almost the same as mine.
I am sharing my code below, please let me know what should be done in order to avoid both in the future.
Code:
using System;
public class Test
{
public static void Main()
{
// your code goes here
string a;
while(true){
a = Console.ReadLine();
if (a == “42”){
break;
}
Console.WriteLine(a);
}
}
}
: