Answer the question
In order to leave comments, you need to log in
How to find the different element of the list?
Suppose there is a list that is guaranteed to consist of either zeros and one unit, or ones and one zero, how can you find the index of a different element?
Answer the question
In order to leave comments, you need to log in
using System;
using System.Collections.Generic;
using System.Linq;
public class Program
{
static public void Main ()
{
List<int> list = new List<int>()
{
0, 1, 0, 0
};
Console.WriteLine(list.IndexOf(1));
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question