Unique Email Addresses

Question Every email consists of a local name and a domain name, separated by the @ sign. For example, in alice@leetcode.com, alice is the local name, and leetcode.com is the domain name. Besides lowercase letters, these emails may contain '.'s or '+'s. If you add periods ('.') between some characters in the local name part of an email address, mail sent there will be forwarded to the same address without dots in the local name. [Read More]

Jewels and Stones

Question You’re given strings J representing the types of stones that are jewels, and S representing the stones you have. Each character in S is a type of stone you have. You want to know how many of the stones you have are also jewels. The letters in J are guaranteed distinct, and all characters in J and S are letters. Letters are case sensitive, so “a” is considered a different type of stone from “A”. [Read More]

Testing Alexa (Amazon Echo) weather application

Question You’re a test engineer at Amazon working with the team who creates skills on Alexa (Amazon Echo). Your team has created a “weather” skill where you can ask Alexa about the weather and it responds with relevant information. How would you test this skill? What would your test cases be? Answer Test automation is possible here and efficient if we automate on the data layer. Before you start answering the questions, you should ask questions to limit your scope of the problem domain. [Read More]

Locator identification strategy in selenium

Choosing the right locator is very important aspect of UI test automation using Selenium. A good locator is more reliable and requires less test maintenance cost. While there are multiple ways of choosing a locator, I usually go with the below order. We will be using this HTML page for locator identification. The HTML for the same page is shared below. <html> <head> <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css"> <title>Login Page</title> </head> <body> <div id="content" class="container"> <h1>Login Page</h1> <form id="loginForm" method="post" action="/authenticate"> <div class="form-group"> <label for="email" class="col-form-label">Email: </label> <input id="email" name="email" class="form-control" /> <label for="password" class="col-form-label">Password: </label> <input id="password" name="password" type="password" class="form-control" /> </div> <div class="form-group row"> <div class="col-sm-1"> <button type="submit" class="btn btn-primary">Login</button> </div> <div class="col-sm-1"> <button type="submit" class="btn btn-primary">Signup</button> </div> <div class="col-sm-1"> <button type="submit" class="btn btn-default">Forgot password? [Read More]

Java program to push zeroes to the end of the array

Problem Given an array of random numbers, push all the zeroes of a given array to the end of the array. Solution We will iterate through the array and move all non zero elements to the front first. We will then fill the remaining array elements with zeroes until we reach the end of the array. Complexity: O(n) package com.interview.prep.programs; public class MoveZeroesToTheEndOfTheArray { public int[] moveZeroes(int[] numbers) throws Exception { if (numbers ! [Read More]

Benefits of using Selenium for test automation

Before you decide on an test automation solution for your web application testing, it would be wise to look at the benefits that selenium provides which I’ll be discussing in this post. Selenium is an open source software. There is no licensing cost and anyone can download and use it for personal learning or business purpose. This could be a great time and cost savings, resulting in a better ROI for the team using it. [Read More]