DEV Community

Cover image for #10daysofcodechallenge by Ingressive for Good (#Day 5)
Dennar David
Dennar David

Posted on • Updated on

#10daysofcodechallenge by Ingressive for Good (#Day 5)

I've just begun a 10-day coding challenge organized by Ingressive for Good and I'll be sharing my thoughts on Day 5 of the challenge.

Let me briefly describe how the challenge works before I share my experience with you. From September 21 through October 30, 2022, the challenge is to solve one common algorithm problem every day for ten days.

Today's algorithm problem was "sorting a string in decreasing order based on the frequency of the characters." It is the 451st algorithm challenge on "Leetcode.com".

I'll now discuss my algorithm solving experience. To do this, I made a map that iterates through the string and stores the characters while keeping track of how often each character appears. The mapped values are then saved in an array, which is sorted after which the array's elements are merged to create the string.

This task was completed in javaScript, took 76 milliseconds to execute, and consumed about 43.9 MB of memory.

Latest comments (0)