All blog posts
-
How to Use ThreadLocal in Java With Selenium WebDriver
What is ThreadLocal? In Java, ThreadLocal is a class that facilitates the usage of thread-local variables. This means it allows the user to store data specific to a particular thread independently. Each thread that accesses a ThreadLocal variable accesses its unique copy of the variable, thus ensuring that changes made by any thread are specific to variables…
-
The Async Nature of Cypress: Don’t Mess with the Timelines in Your Cypress Tests ‘Dual-Verse’
ACT 1: EXPOSITION Cypress is often recognized for its asynchronous test execution model, and this very characteristic is frequently cited as the main reason behind flaky tests. Honestly, I’d have to agree—but only to an extent. The real issue isn’t asynchrony itself, but rather how it’s misused, which often stems from a lack of understanding.…
-
Grokking 75:Pair with Target Sum
Problem Statement Given an array of numbers sorted in ascending order and a target sum, find a pair in the array whose sum is equal to the given target. If no such pair exists return [-1, -1]. Write a function to return the indices of the two numbers (i.e. the pair) such that they add up…
-
Grokking 75:H-Index (medium)
Problem Statement Given an integer array citations where citations[i] represents the number of times a researcher’s ith paper has been cited, return the researcher’s h-index. The h-index is defined as the maximum number h such that the researcher has h papers with at least h citations each. Examples Example 1 Example 2 Example 3 Constraints: Solution To solve this problem, we use an array to count the number…
-
Grokking 75:Jump Game II(medium)
Problem Statement You are given an array nums containing n integers, where nums[i] represents the maximum length of a forward jump you can make from index i. You are initially positioned at nums[0]. Return the minimum number of jumps needed to reach from the start to the end of the array. Examples Example 1: Example 2: Example 3: Constraints: Solution To solve this problem, we need to keep track of the…
-
Grokking 75:Jump Game (medium)
Problem Statement You are given an array of integers nums. You start at the first index of the array and each element in nums represents the maximum number of steps you can jump forward from that position. Return true if you can reach the last index, or false otherwise. Examples Example 1 Example 2 Example 3 Constraints: Solution To solve this problem, we will use a greedy…
-
Grokking 75:Zigzag Conversion
Problem Statement Given a string s and a numRows integer representing the number of rows, write the string in a zigzag pattern on the given number of rows and then read it line by line, and return the resultant string. The zigzag pattern means writing characters in a diagonal down-and-up fashion. For example, given the string “HELLOPROGRAMMING” and 4 rows, the pattern would…
-
Grokking 75:Best Time to Buy and Sell Stock
Problem Statement You are given an array prices where prices[i] is the price of a given stock on the day. You want to maximize your profit by choosing a single day to buy one stock and choosing a different day in the future to sell that stock. Return the maximum profit you can achieve from this transaction. If you cannot achieve any profit, return…
-
How importing from Playwright works
How importing from Playwright works Peering into Playwright’s import process Whenever you import playwright, there’s a lot of code being executed before you can actually execute anything with its APIs. In the following short snippet Playwright is initializing a server controlling the browser instance, building a connection between its underlying client and server library, and…
-
Architecture of Playwright
Architecture of Playwright Intro When you load up the repository for the Playwright library, you may be overwhelmed by the numerous packages living both inside the packages folder, and within the root folder. In addition, if you try and trace the code used by a Playwright test, you will likely be befuddled by the many folders in the package…