Software engineering and personal development

Tag: sort

How to Quickly Find the Largest and Smallest Element in a List in Python

eyeglasses with black frames on white desk
Photo by Temple Cerulean on Unsplash

One of the first algorithms that we are usually taught is finding either the smallest or the largest element in a list of elements by iterating through every element in a list.

Let’s assume that we are trying to find the smallest element in a list.

The algorithm is quite straightforward and intuitive even for a 5-year-old: You assume that the first element is the smallest and save its value in a variable.

Continue reading

How to Check Whether 2 Strings Are Anagrams in Python Using Counter

A MacBook with lines of code on its screen on a busy desk
Photo by Christopher Gower on Unsplash

Checking whether a word is an anagram of another one can be a question that is quite common in coding interviews.

If you don’t know what an anagram is, here is a definition:

An anagram is a word or phrase formed by rearranging the letters of a different word or phrase, typically using all the original letters exactly once. For example, the word anagram itself can be rearranged into nag a ram, also the word binary into brainy and the word adobe into abode. 

Continue reading

© 2024 Fatos Morina

Theme by Anders NorenUp ↑