G
G
Georgy Kuznetsov2021-08-22 12:05:42
C++ / C#
Georgy Kuznetsov, 2021-08-22 12:05:42

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

2 answer(s)
L
lwich, 2021-08-22
@JoeSmith3100

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));
    }
}

A
alexbprofit, 2021-08-22
@alexbprofit

example

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question