[Google Interview] Shuffle the Array
[toc] 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 … Read more
Python __floordiv__() Magic Method
Syntax object.__floordiv__(self, other) The Python __floordiv__() method implements the integer division operation // called floor division—as opposed to the true division operation /. For example to evaluate the expression x // y, Python attempts to call x.__floordiv__(y). If the method is not implemented, Python first attempts to call __rfloordiv__ on the right operand and if … Read more
How to Select a Drop-Down Menu Value with Python Selenium
One of the finest open-source browser automation tools recognized in todayβs world is selenium and the βSelectβ class of selenium WebDriver enables us to handle the dropdown menu smoothly. Today, we will try to figure out all the intricacies of the βSelectβ class practically. Purpose of the Select Class The βSelectβ class in selenium allows … Read more
Clicking a Button with Selenium in Python
Modern web pages are fitted with so many functionalities. Buttons are one of the fundamental components of them. Selenium Python API bindings allow us to access the Selenium WebDrivers to click a button automatically. In this article, we will follow step by step approach to click on buttons. Setting Up the Environment We need to … Read more
[Google Interview] License Key Formatting
[toc] 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 … Read more
Python Read Binary File
During your career as a Pythonista, you will most likely find yourself required to work with binary data. See the examples outlined below to efficiently read/write to a Binary file. Preparation Before any data manipulation can occur, one (1) new library will require installation. The NumPy library supports multi-dimensional arrays and matrices in addition to … Read more
How to Use Pytest Fixtures
In this article, you’ll deep dive into a powerful testing feature in Python called Pytest Fixtures. Feel free to dive into our background articles on Pytest in case you need a quick refresher (with video)! Pytest β A Complete Overview Pytest β How to Run Tests Efficiently You can watch this tutorial in video format … Read more
The Quickselect Algorithm – A Simple Guide with Video
What is the Quickselect algorithm? The Quickselect algorithm is a computer algorithm designed to find the kth (e.g. smallest or largest) element from an unordered list. It is based on the idea behind the Quicksort algorithm, invented by the same author, Sir Charles Anthony Richard (Tony) Hoare. Here, k stands for the index of an … Read more
Python __truediv__() Magic Method
Syntax object.__truediv__(self, other) The Python __truediv__() method is called to implement the normal division operation / called true division—as opposed to the floor division operation //. For example to evaluate the expression x / y, Python attempts to call x.__truediv__(y). We call this a “Dunder Method” for “Double Underscore Method” (also called “magic method”). To … Read more
Python __matmul__() Magic Method
Syntax object.__matmul__(self, other) The Python __matmul__() method is called to implement the matrix multiplication operation @. For example to evaluate the expression x @ y, Python attempts to call x.__matmul__(y). We call this a “Dunder Method” for “Double Underscore Method” (also called “magic method”). To get a list of all dunder methods with explanation, check … Read more
The Pandas filter() Method in Python
The Pandas DataFrame filter() Method In this tutorial, we will have a look at the Pandas filter() method. We will see what this function does and how we can apply it to our dataframes. As the name suggests, the filter() method filters our dataframe. To be more specific, the method subsets the rows or columns … Read more