DouDigits
ex: 12, 110, 373333
using System;
using System.Linq;
using System.IO;
using System.Text;
using System.Collections;
using System.Collections.Generic;
class Solution
{
public static string IsDuoDigit(int number)
{
// Write your code here
// To debug: Console.Error.WriteLine("Debug messages...");
var sbsNum = Math.Abs(number);
var numStr = sbsNum.ToString();
List<string> list = new List<string>();
for(int i = 0; i< numStr.Length; i++){
if(!list.Contains(numStr[i].ToString())){
list.Add(numStr[i].ToString());
}
}
if(list.Count <= 2 ){
return "y";
}
return "n";
}
/* Ignore and do not change the code below */
static void Main(string[] args)
{
int number = int.Parse(Console.ReadLine());
var stdtoutWriter = Console.Out;
Console.SetOut(Console.Error);
string result = IsDuoDigit(number);
Console.SetOut(stdtoutWriter);
Console.WriteLine(result);
}
/* Ignore and do not change the code above */
}
Aucun commentaire:
Enregistrer un commentaire