## 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 Count the Number of Words in a String in Python

You can count the number of words in string using one of the following options: Method 1: Using split() and len() Method 2: Using regex Method 3: Using a For Loop Method 4: Using count Method 5: Using sum Problem Formulation Given a string – sentence. How many words does the string sentence have within … 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

Company Tag: Google Problem Formulation We define the usage of capitals in a word to be right when one of the following cases holds: Rule 1: All letters in this word are capitals, like “USA”. Rule 2: All letters in this word are not capitals, like “welcome”. Rule 3: Only the first letter in this … Read more

## [Google Interview] Shuffle the Array

Company Tags: Google, Adobe, Apple, Bloomberg, Microsoft Problem Description Given the array nums consisting of 2n elements in the form [x1, x2,…,xn, y1, y2,…, yn]. Return the array in the form [x1, y1, x2, y2,…, xn, yn]. Constraints: 1 <= n <= 500 nums.length == 2n 1 <= nums[i] <= 10^3 Examples Let’s have a … Read more

Company tags: Google, Capital One Problem Formulation You are given a license key represented as a string s that consists of only alphanumeric characters and dashes. The string is separated into n + 1 groups by n dashes. You are also given an integer k. We want to reformat the string s such that each … Read more