## How to Count the Number of Words in a String in Python

Problem Formulation Given a string – sentence. How many words does the string sentence have within it? Examples: INPUT sentence = “Finxter helps you to master Python.” OUTPUT Number of words: 6 INPUT sentence = “””Lorem ipsum dolor sit amet. Consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.””” OUTPUT … Read more

## How to Count the Number of Unique Values in a List in Python?

Problem Statement: Consider that you have been given a list in Python. How will you count the number of unique values in the list? Example: Let’s visualize the problem with the help of an example: Given: li = [‘a’, ‘a’, ‘b’, ‘c’, ‘b’, ‘d’, ‘d’, ‘a’]Output: The unique values in the given list are ‘a’, ‘b’, ‘c’, ‘d’. … Read more

## Python – How to Find the Longest Substring in Alphabetical Order?

Programming Challenge 💬 Challenge: Given a Python string. Find the longest substring for which holds that all of its characters are in alphabetical order so that the first character comes earlier in the alphabet than the second character, and so on. Here are three examples: You get the point. 🙂 Next, I’ll show you three … Read more

## How to Find All Palindromes in a Python String?

Coding Challenge 💬 Challenge: Given a string. How to find all palindromes in the string? For comprehensibility, allow me to quickly add a definition of the term palindrome: 💡 Definition: A palindrome is a sequence of characters that reads the same backward as forward such as ‘madam’, ‘anna’, or ‘101’. This article wants to give … Read more

## Find Longest Palindrome in a Python String (Easy)

Coding Challenge 💬 Challenge: Given a string. How to find the longest palindrome in the string? For comprehensibility, allow me to quickly add a definition of the term palindrome: 💡 Definition: A palindrome is a sequence of characters that reads the same backward as forward such as ‘madam’, ‘anna’, or ‘101’. This article wants to … Read more

## How to Find Number of Digits in an Integer?

To find the number of digits in an integer you can use one of the following methods: (1) Use Iteration (2) Use str()+len() functions (3) Use int(math.log10(x)) +1 (4) Use Recursion Problem Formulation Given: An integer value. Question: Find the number of digits in the integer/number given. Test Cases: Input: num = 123 Output: 3 … Read more

## How To Find the Most Common Elements of the List in Python?

In today’s article, let’s discuss one of the most asked interview questions: How to find the most common elements of the list in Python? Although this might sound like a simple question, the approach we use to answer this question gives the interviewer an idea of our knowledge and expertise in Python.  Understanding the Challenge … Read more

## Python Palindromes One-Liner

This one-liner introduces another basic computer science term: palindromes. Similar to anagrams, palindromes are a popular coding interview question. First things first: What is a Palindrome? “A palindrome is a word, number, phrase, or other sequence of characters which reads the same backward as forward, such as madam or racecar or the number 10201.“ [source] … Read more

## Python Anagrams in One Line Python

Why Learning about Python Anagrams? A popular question in programming interviews is to create an anagram checker. The interviewer wants to test your knowledge about the basic terminology in computer science, and how good you are at developing your own simple algorithms to solve the problems you are facing. In this article, you’ll learn about … Read more

## [Google Interview] The 3 Sum Problem

Company Tags: Google, Adobe, Amazon, Apple, Bloomberg, Facebook, Oracle, Microsoft, Tesla Problem Statement Given an integer array nums, return all the triplets [nums[i], nums[j], nums[k]] such that i != j, i != k, and j != k, and nums[i] + nums[j] + nums[k] == 0. Note: that the solution set must not contain duplicate triplets. … Read more