IT Codes ZoneRevature

Revature Previous Coding Questions

🔥 Revature Previous Coding Questions with Java & Python Solutions

Welcome to this specially curated post featuring Revature Previous Coding Questions.
Each problem includes:

  • A clear problem statement
  • Java and Python solutions
  • Example input/output
  • Concise and clear explanation

Let’s get started! 🚀


✅ Problem 1: Sum of Arithmetic Progression

📝 Problem Statement

You are given an arithmetic progression (AP) with N terms.
Your task is to calculate the sum of the series.
You may derive the first term A and common difference D from the input.

📐 Formula Used

Sum = (N / 2) × (2A + (N – 1) × D)

🔢 Input

  • Integer N — number of terms
  • N space-separated integers forming the AP

🧾 Output

  • A single integer — the sum of the AP

✅ Example

Input:
5
2 4 6 8 10

Output:
30

🔣Code

🔍 Explanation

We extract the first element A and compute the common difference D.
Using the arithmetic progression sum formula, we calculate and print the total.

✅ Problem 2: Pointer Conversion in Code

📝 Problem Statement

Given C-style code, convert expressions like a*b into a->b,
except on lines that start with comments (//).

🔢 Input

  • Up to 100 lines of C-style code
  • Each line ≤ 50 characters

🧾 Output

  • Modified code with * replaced by -> where appropriate

✅ Example

Input:
// ignore this line
a*b = 5;
c*d = a*b;

Output:
// ignore this line
a->b = 5;
c->d = a->b;

🔣Code

🔍 Explanation

Using regex, we safely convert pointer-like expressions to the -> format
without affecting comment lines that start with //.

✅ Problem 3: Previous 5 Characters

📝 Problem Statement

Given a capital letter C, print the 5 letters that precede it alphabetically.

🔢 Input

  • A single uppercase letter C (C > ‘E’)

🧾 Output

  • 5 space-separated characters before C

✅ Example

Input:
K

Output:
F G H I J

🔣Code

🔍 Explanation

We use ASCII math to get previous characters using ord() and chr(),
then loop from -5 to -1 to print the correct sequence.

✅ Problem 4: Average of Middle Digits

📝 Problem Statement

Given an integer:

  • If it has even digits → take 2 middle digits
  • If odd → take 3 middle digits

Return the floor average of these digits.

🔢 Input

  • A single integer with at least 2 digits

🧾 Output

  • Integer — floor of the average

✅ Example

Input:
123456

Output:
4
(Middle digits: 3 and 4 → average = (3+4)//2 = 3)

🔣Code

🔍 Explanation

We get the middle digits based on string length and
calculate the integer (floor) average using integer division.

✅ Problem 5: First 4-Letter Word Position

📝 Problem Statement

Given a sentence, find the 1-based position of the first word with exactly 4 characters.

🔢 Input

  • A sentence

🧾 Output

  • Index of the first 4-letter word or -1

✅ Example

Input:
We love open code!

Output:
2

🔣Code

🔍 Explanation

The Java and Python programs take a line of text, break it into words, and find the first word that has exactly 4 letters. They then print its position (starting from 1), or -1 if no such word exists.

✅ Problem 6: Third Smallest Element Position

📝 Problem Statement

Given a list of integers, find the 1-based position of the third smallest unique element.
If there are fewer than 3 unique elements, return -1.

🔢 Input

  • First line: integer n
  • Second line: n space-separated integers

🧾 Output

  • Index of third smallest unique number or -1

✅ Example

Input:
6
4 1 2 1 2 3

Output:
6

🔣Code

🔍 Explanation

We create a sorted set to get unique values.
The third element is selected, and we find its first occurrence index (1-based).

🚨 Revature Overview!

Curious about how Revature’s selection process works, the rounds involved, and other key details? Don’t miss this complete breakdown:
🌐 https://nextgenkodinghub.in/revature-overview/

Wishing you the best of luck! 💼✨


Thanks for visiting! Explore the categories below for more exciting and useful content.


Leave a Reply

Your email address will not be published. Required fields are marked *