Objective
Today we’re discussing scope.
The absolute difference between two integers, a and b, is written as |a – b|. The maximum absolute difference between two integers in a set of positive
integers, elements, is the largest absolute difference between any two integers in elements.
The Difference class is started for you in the editor. It has a private integer array (elements) for storin
Date: May 21, 2023, 12:06 pm Author: Akram Hossain
Objective
Today, we will extend what we learned yesterday about Inheritance to Abstract Classes. Because this is a very specific object oriented concept,
submissions are limited to the few languages that use this construct.
Task
Given a Book class and a Solution class, write a MyBook class that does the following:
Inherits from Book
Has a parameterized constructor taking these 3 param
Date: May 21, 2023, 11:56 am Author: Akram Hossain
Objective
Today, we’re delving into Inheritance.
Task
You are given two classes, Person and Student, where Person is the base class and Student is the derived class.
Completed code for Person and a declaration for Student are provided for you in the editor.
Observe that Student inherits all the properties of Person.
Complete the Student class by writing the following:
A Student class
Date: May 20, 2023, 12:42 pm Author: Akram Hossain
Objective
Today, we are building on our knowledge of arrays by adding another dimension.
ContextGiven a 6 x 6 2D Array, A:
1 1 1 0 0 0
0 1 0 0 0 0
1 1 1 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
We define an hourglass in A to be a subset of values with indices falling in this pattern in A‘s graphical representation:
a b c
d
e f g
There are 16 hourglasses in A, and an hourglass
Date: May 20, 2023, 12:17 pm Author: Akram Hossain
Objective
Today, we’re working with binary numbers.
Task
Given a base-10 integer, n, convert it to binary (base-2). Then find and print the base-10 integer denoting the maximum number of consecutive 1‘s in n‘s
binary representation. When working with different bases, it is common to show the base as a subscript.
Example
n = 125
The binary representation of 12510 is 11111012. In base 1
Date: May 20, 2023, 12:04 pm Author: Akram Hossain
Recursive Method for Calculating Factorial
factorial(N) = {1/n X factorial(N-1) N ≤ 1/otherwise
Function Description
Complete the factorial function in the editor below.
Be sure to use recursion.
factorial has the following paramter:
int n: an integer
Returns
int: the factorial of n
Note: If you fail to use recursion or fail to name your recursive function factorial or Fac
Date: January 2, 2023, 8:03 am Author: Akram Hossain
Task:
Given n names and phone numbers, assemble a phone book that maps friends' names to their respective phone numbers.
You will then be given an unknown number of names to query your phone book for.
For each named queried, print the associated entry from your phone book on a new line in the form name=phoneNumber;
if an entry for name is not found, print Not found instead.
Note: Your p
Date: June 25, 2022, 7:20 am Author: Akram Hossain
Task
Given an array,A, of N integers, print A's elements in reverse order as a single line of space-separated numbers.
Example
A=[1,2,3,4]
Print 4 3 2 1. Each integer is separated by one space.
Input Format
The first line contains an integer,N(the size of our array).
The second line contains N space-separated integers that describe array A's elements.
Constraints
1
Date: January 4, 2022, 11:33 am Author: Akram Hossain
Hacker Rank: Day 6: Let's Review
Task
Given a string,S, of length N that is indexed from 0 to N-1, print its even-indexed
and odd-indexed characters as 2 space-separated
strings on a single line (see the Sample below for more detail).Note: 0 is considered to be an even index.
Example
s = abdecf
Print abc def
Input Format
The first line contains an integer, T(the number of test cases).
Date: November 20, 2021, 4:12 pm Author: Akram Hossain
Task:
Write a Person class with an instance variable, age, and a constructor that takes an integer, initialAge, as a parameter.
The constructor must assign initialAge to age after confirming the argument passed as initialAge is not negative;
if a negative argument is passed as initialAge, the constructor should set age to 0 and print Age is not valid, setting age to 0..
In addition, you must
Date: June 13, 2021, 12:58 pm Author: Akram Hossain
Task:
Given an integer,perform the following conditional actions:
If n is odd, print Weird
If n is even and in the inclusive range of 2 to 5, print Not Weird
If n is even and in the inclusive range of 6 to 20, print Weird
If n is even and greater than 20, print Not Weird
Input Format:
A single line containing a positive integer, n.
Constraints:
1 0 && $i =2 && $i =6 && $i 20){
Date: June 10, 2021, 1:46 pm Author: Akram Hossain