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 *