A square triple (a,b,c) is a triple where a, b, and c are integers and a2 + b2 = c2. Given an integer n, return the number of square triples such that 1 <= a, b, c <= n. Example 1: Input: n = 5Output: 2Explanation: The square triples are (3,4,5) and (4,3,5). Example 2:…
Tag: algorithm
Leet code problem 1929: – Concatenation of Array
Given an integer array nums of length n, you want to create an array ans of length 2n where ans[i] == nums[i] and ans[i + n] == nums[i] for 0 <= i < n (0-indexed). Specifically, ans is the concatenation of two nums arrays. Return the array ans. Example 1: Input: nums = [1,2,1]Output: [1,2,1,1,2,1]Explanation:…
leetcode solution of problem 1893 in java
Check if All the Integers in a Range Are Covered You are given a 2D integer array ranges and two integers left and right. Each ranges[i] = [starti, endi] represents an inclusive interval between starti and endi. Return true if each integer in the inclusive range [left, right] is covered by at least one interval…
leetcode solution of 1880 in java
Check if Word Equals Summation of Two Words The letter value of a letter is its position in the alphabet starting from 0 (i.e. ‘a’ -> 0, ‘b’ -> 1, ‘c’ -> 2, etc.). The numerical value of some string of lowercase English letters s is the concatenation of the letter values of each letter…
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…
leetcode 1827 solution in java
Minimum Operations to Make the Array Increasing You are given an integer array nums (0-indexed). In one operation, you can choose an element of the array and increment it by 1. For example, if nums = [1,2,3], you can choose to increment nums[1] to make nums = [1,3,3]. Return the minimum number of operations needed…
leetcode 1854 solution in java
Maximum Population Year Solution This above problem is taken from https://leetcode.com/problems/maximum-population-year/ Solution:- Approach:- Code:- public static int methodeName(int[][] arr) { //defined one array years with size 2051 int[] years = new int[2051]; //Now hover over the goven 2d array for (int[] log : arr) { //given array is {1952,1961},{1953,1961 } //so for first iteration log…