---
title: "Discussion on \"Fastest(?) way to find most frequent element of IEnumerable<int>\" | Hashnode"
description: "Discussion on \"Fastest(?) way to find most frequent element of IEnumerable<int>\". Friend got an interview task to code a method that finds and returns the most frequent element in a large list of integers. It took 40 minutes, why so long?"
url: "https://hashnode.com/posts/fastest-way-to-find-most-frequent-element-of-ienumerableint/641da033f4983a52bd4fd33b"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Fastest(?) way to find most frequent element of IEnumerable<int>](https://krystianzakrys.hashnode.dev/fastest-way-to-find-most-frequent-element-of-ienumerableint?utm_source=hashnode&utm_medium=feed)

Friend got an interview task to code a method that finds and returns the most frequent element in a large list of integers. It took 40 minutes, why so long?

Mar 24, 2023 · 5 min read · krystianzakrys.hashnode.dev  
Read the article

-   [#csharp](https://hashnode.com/tag/csharp)
-   [#programming-tips](https://hashnode.com/tag/programming-tips)
-   [#algorithms](https://hashnode.com/tag/algorithms)
-   [#data-structures](https://hashnode.com/tag/data-structures)
-   [#developer](https://hashnode.com/tag/developer)

## Written by

[Krystian Zakryś](https://hashnode.com/@krystianzakrys)

@krystianzakrys

  
[View profile](https://hashnode.com/@krystianzakrys)

👨‍💻 Software Engineer | ☁️ Azure DevOps Engineer & Solutions Architect Expert | 💻 .NET | 🌐 Angular | 📱 Flutter | 🚀 Software lover

👨‍💻 Software Engineer passionate about solving problems and building user-friendly apps. Certified Azure DevOps Engineer &amp; Azure Solutions Architect Expert ☁️ 💻 Proficient in .NET, Angular, and Flutter. 🚀 Focused on fintech innovation and developing my own apps. A strong believer in continuous learning and sharing knowledge through blogs and mentoring. Outside of tech? 🎮 Gamer, 📖 Avid reader, and a fan of Warhammer 40k 🛡️. Exploring the intersection of creativity and code every day!

## Responses 1

Markdown supported · ⌘↵ to post

[Mark Cooke](https://hashnode.com/@NickelCoder)

[Mar 24, 2023](https://hashnode.com/posts/fastest-way-to-find-most-frequent-element-of-ienumerableint/641da033f4983a52bd4fd33b/comment/641e076e05c482464c90a5ea)

I would not take a job where they ask such questions. Because in a business, it's almost always better to go with the cleanest and most maintainable solution, not the most performant. If I had been asked this question, my first response would be "Why does this need to be performant?" Junior developers blindly write code without knowing why something needs to be done a certain way.

[Krystian Zakryś](https://hashnode.com/@krystianzakrys)

[Mar 24, 2023](https://hashnode.com/posts/fastest-way-to-find-most-frequent-element-of-ienumerableint/641da033f4983a52bd4fd33b/comment/641e076e05c482464c90a5ea#reply-641e094e05c482464c90a628)

Theres always pros and cons to take into consideration. Especially with large systems linked to the financial sector ;) That's why I checked how data variety changes finding times. This was a semi-cool experiment I think :)
