Can Ürek
Can Ürek

Can Ürek

Coding challenges

Photo by Olav Ahrens Røtne on Unsplash

Coding challenges

Can Ürek's photo
Can Ürek
·Sep 12, 2022·

3 min read

Subscribe to my newsletter and never miss my upcoming articles

Play this article

Let's talk about coding challenges in this article.

There are many websites where we can test our coding skills, and many different questions are waiting for us to solve them.

Some companies, even the biggest ones, use these sites to evaluate candidates. And to be successful in these assessments, you need to know some fundamental things about coding.

I am not saying that I am very successful in all these matters. I'll just try to share some information and resources, and at the end of the article, I will share my solution to a question.

Data structures and Algorithms will be our starting points. These are not dependent on any programming language, and all languages have the same structure or an equivalent one.

Some people, especially juniors, think that these are not necessary. But there are some use cases for all of them.

Most developers nowadays work with frameworks and CRUD scenarios. But some of them know that this is not enough and that this is not seniority. Working like that is just like filling empty spaces, and everyone can do that. And you need to know the fundamentals if you want to do more.

Anyway, let's start with the Data Structures.

You can see commonly used data structures at the following link and get more info by clicking on their names. There are some good explanations.

https://www.bigocheatsheet.com/

My primary programming language is C#. That's why I also wanted to share this beautiful article too.

https://dev.to/adavidoaiei/fundamental-data-structures-and-algorithms-in-c-4ocf

And the below resource is a very good compilation.

https://github.com/mtdvio/every-programmer-should-know

I'm assuming we have some ideas on how and where we can store the data we want to work on, and now we can discuss how we can manipulate it to get the desired result.

So our new topic is Algorithms.

There is no limit when talking about algorithms. We'll talk about commonly used algorithms, but as you can see from the description below, there is no limit.

"In mathematics and computer science, an algorithm is a finite sequence of rigorous instructions, typically used to solve a class of specific problems or perform a computation. Algorithms are used as specifications for performing calculations and data processing."

Sorting is one of the top topics in algorithms. And we should choose the right algorithm according to our needs. The following resource can give you some ideas.

https://www.toptal.com/developers/sorting-algorithms

Keep in mind that it takes a lot of practice to better understand algorithms and data structures and to choose and use the right ones

At the following link, you can get more info about algorithms.

https://www.calltutors.com/blog/types-of-algorithms/

I guess there are some links in all of the coding challenges sites to work on the different types of algorithms. For example, on the hacker rank website, you can access it from the following link.

https://www.hackerrank.com/domains/algorithms

Screen Shot 2022-09-12 at 15.14.36.png

As you can imagine, there is much more detail on all of these things. But the information that I tried to share may be a good start for some people.

And finally, I will share my own solution to a problem. Of course, I'm not sure it was a perfect solution. And I think the hardest part of solving these questions is understanding them. But maybe someone can show me a better approach, and I can review my solution.

The link to the problem is below.

https://www.hackerrank.com/challenges/countingsort4/problem

And the codes for my solution are below.

var middleOfArr = arr.Count / 2;

var filterArr = arr.Take(middleOfArr).ToHashSet();

var sortedArr = arr.OrderBy(x => int.Parse(x[0])).ToList();

var sb = new StringBuilder();

foreach(var item in sortedArr)
{
    var index = item[0];
    var str = item[1];

    var hasFilter = filterArr.Contains(item);

    if(!hasFilter)
    {
        sb.Append(str + " ");
        continue;
    }

    sb.Append("- ");
}

Console.Write(sb.ToString(), Console.Out);

I hope this article will be useful for some people.

See you next time.

 
Share this