leetcode 2037 solution in java

Minimum Number of Moves to Seat Everyone There are n seats and n students in a room. You are given an array seats of length n, where seats[i] is the position of the ith seat. You are also given the array students of length n, where students[j] is the position of the jth student. You…

leetcode 2006 solution in java

Count Number of Pairs With Absolute Difference K Given an integer array nums and an integer k, return the number of pairs (i, j) where i < j such that |nums[i] – nums[j]| == k. The value of |x| is defined as: x if x >= 0. -x if x < 0. This above problem…

findElement method in Selenium WebDriver

To find any web element in any webpage this findElement method is used by Selenium WebDriver. This is an abstract method and defined under the SearchContext interface. as mentioned in the source code. But this SeachContext interface is also implemented by the SeleniumWebDriver interface as mentioned in here. As mentioned in the source code comment…

Selenium WebDriver is a class or interface?

The best way to answer this question is to check the source code of Selenium WebDriver. The source code can be found here. In that source code it is clearly mentioned that, the Selenium WebDriver is an interface. The clear and concise source code of selenium WebDriver interface is mentioned below:- import org.openqa.selenium.logging.LoggingPreferences; import org.openqa.selenium.logging.Logs;…

lambda examples in java language with code

Lambda expression is used for the implementation of the functional interfaces. Functional interface is those interfaces which has only one abstract method. We can declare an interface as functional interface by using the annotation @FunctionalInterface. e.g. Comparator interface in java is a functional interface. Please visit the official site for more information:- lambdaexpressions Example 1:-…

leetcode solution of 1876 in java

Substrings of Size Three with Distinct Characters A string is good if there are no repeated characters. Given a string s​​​​​, return the number of good substrings of length three in s​​​​​​. Note that if there are multiple occurrences of the same substring, every occurrence should be counted. A substring is a contiguous sequence of…

How many numbers are smaller than the current number

How many numbers are smaller than the current number:- Given the array nums, for each nums[i] find out how many numbers in the array are smaller than it. That is, for each nums[i] you have to count the number of valid j’s such that j != i and nums[j] < nums[i]. Return the answer in an array….

leetcode solution of 1832 in java

Check if the Sentence Is Pangram:- A pangram is a sentence where every letter of the English alphabet appears at least once. Given a string sentence containing only lowercase English letters, returntrue if sentence is a pangram, or false otherwise. Solution:- Flow Diagram:- Code Block:- public static boolean checkIfPangram(String sentence) { Set s = new…