So today’s task was so easy I’m going to do another one because I solved it way too fast. It’s really not that hard if you know some built-in data structures.
Given an n-length Array of numbers between -1,000,000 to 1,000,000, find the number of distinct values in the array.
A = [1,4,2,6,8,2,3,6] returns 6
The idea is to eliminate duplicated numbers from the Array. For this, we use a Set and then get the size of this set which finishes the solution.
const solution = A => new Set(A).size
I actually spent more time writing this than thinking about the solution😁.
Today we disemvowel a string. That word is beautiful and means to remove every vowel out of a string. Disemvowel it!
Today I take a break from reading and tackle the simple problem of counting bits in Rust. This is my first Rust solution.
Today I’m looking at functions and loops. They are an important part of any language and deserve a closer look.
Today I take a look at cargo, Rust’s answer to npm and yarn. It’s a tool that makes a developer’s life that much easier.