1. You are given a number n, representing the number of stairs in a staircase. 2. You are on the 0th step and are required to climb to the top. 3. You are given n numbers, where ith element's value represents - till how far from the step you could jump to in a single move. You can of course jump fewer number of steps in the move. 4. You are required to print the number of different paths via which you can climb to the top. Input Format A number n .. n more elements Output Format A number representing the number of ways to climb the stairs from 0 to top. Constraints 0 <= n <= 20 0 <= n1, n2, .. <= 20 Sample Input 10 3 3 0 2 1 2 4 2 0 0 Sample Output 5 Solution: import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws Exception { // write your code here Scanner sc = new Scanner(System.in); ...
Problem: Operators are symbols that perform operations on variables and values. For example, + is an operator used for addition , while * is also an operator used for multiplication . Operators in Java can be classified into 6 types: Arithmetic Operators Assignment Operators Relational Operators Logical Operators Unary Operators Bitwise Operators References: Click Here . We will discuss about arithmetic operators and rest you can study from the references mentioned above. Arithmetic Operators: Arithmetic operators are used to perform arithmetic operations on variables and data. For example, a + b; Here, the + operator is used to add two variables a and b. Similarly, there are various other arithmetic operators in Java. Operator Operation + Addition - Subtraction * Multiplication / Division % Modulo Operation (Remainder after division) Task: You are given two integers as input a and b You need to perform several...
Problem: Chef opened a company which manufactures cars and bikes. Each car requires 4 4 tyres while each bike requires 2 2 tyres. Chef has a total of N N tyres ( N N is even). He wants to manufacture maximum number of cars from these tyres and then manufacture bikes from the remaining tyres. Chef's friend went to Chef to purchase a bike. If Chef's company has manufactured even a single bike then Chef's friend will be able to purchase it. Determine whether he will be able to purchase the bike or not. Input Format The first line contains an integer T T denoting the number of test cases. The T T test cases then follow. The first line of each test case contains an integer N N denoting the number of tyres. Output Format For each test case, output YES or NO depending on whether Chef's friend will be able to purchase the bike or not. Output is case insensitive. Constraints 1 ≤ T ≤ 100 1 ≤ T ≤...
Problem: In computer programming, we use the if statement to control the flow of the program. For example, if a certain condition is met, then run a specific block of code. Otherwise, run another code. For example: class Main { public static void main(String[] args) { int number = 0; // checks if number is greater than 0 if (number > 0) { System.out.println("The number is positive."); } // checks if number is less than 0 else if (number < 0) { System.out.println("The number is negative."); } // if both condition is false else { System.out.println("The number is 0."); } } } Output The number is 0. In the above example, we are checking whether the number is positive, negative, or zero . Here, we have two condition expressions: number > 0 - checks if the number is greater than 0 number < 0 - checks if the number is less than 0 Here, the value of the number is 0 . So both th...
Write a query to create Customer_info table with constraints mentioned. Refer the below schema Result Description Summary of tests +------------------------------+ | 3 tests run / 3 test passed | +------------------------------+
RDBMS Data Definition Language Drop Sales Info table(child) Refer the following schema and drop Sales Info table. Evaluation Result: Result Description Summary of tests +------------------------------+ | 1 tests run / 1 test passed | +------------------------------+
Comments
Post a Comment