PwC Coding Questions and Answers

Most Asked PwC Coding Questions with Solutions

Find the most asked PWC Coding Questions and answers 2023, asked for freshers in various hiring exams. If you are preparing for PwC recruitment examinations you can refer to this page for more information.

coding questions asked

About PwC

PricewaterhouseCoopers is an international professional service brand of firms that work under PwC. It is considered one of the Big Four accounting firms along with Deloitte, EY and KPMG.

Prime Course Trailer

PwC Recruitment Process

PwC Recruitment Process constitutes of the following rounds:-
  • Online Tests
  • Interview

PwC Online Test

Round Name Number of Questions
Aptitude 15 questions
Verbal 5 questions
Conceptual CS 20 questions
Quality Mindset 5 questions
Programming 1 question

PwC Eligibility Criteria

PwC hires both B.Tech and MCA graduates. The eligibility criteria for both the departments are:

PwC Salary

PwC offers a package of 6 lakhs per annum. It is fixed pay wit no variables.

Related Banners

Get PrepInsta Prime & get Access to all 200+ courses offered by PrepInsta in One Subscription

Sample PwC Coding Questions and Answers 2023

QUESTION : Order check 

Problem Statement: In an IT company there are n number of Employees , they are asked to stand in ascending order according to their heights.But some employees are not currently standing in their correct position.

Your task is to find how many employees are there who are not standing in their correct positions.

Example

height=[1,2,1,3,3,4,3]

The 4 employees at indices 1,2,5 and 6 are not in the right positions. The correct positions are (1,1,2,3,3,3,4).Return 4.

Function Description

Complete the function countEmployees in the editor below.

count Employee has the following parameter(s):

int height[n]:an array of heights in the order the employees are standing

Returns:

Int : the number of employees not standing in the correct positions

Constraints

  •    1<=n<=10^5
  •    1<=height[i]<=10^9

Sample case 0

Sample input 0

7 ->height[] size n=7

1

2

1

3

3

4

3

Sample output 0:

4

Explanation

The four employees who are  not standing in the correct positions are at indices [1,2,5,6] return 4. The correct positions are [1,1,2,3,3,3,4].

QUESTION : Maximum Toys

In a toy shop there are a number of toys presented with several various – priced toys in a specific order. You have a limited budget and would like to select the greatest number of consecutive toys that fit within the budget. Given prices of the toys and your budget, what is the maximum number of toys that can be purchased for your child?

Example:

prices=[1,4,5,3,2,1,6]

money=6

All sub arrays that sum to less than or equal to 6 .

length 1:  [1] [4] [5] [3] [2] [1] [6]

length 2:  [1,4] [3,2] [2,1] 

length 3: [3,2,1]

The longest of these or the maximum number of toys that can be purchased is 3.

Function description

Complete the function getMaxToys in the editor below 

getMaxToys has the following parameters:

int prices[n] : the prices of the various toys

int money: the amount of money you can spend on toys 

Returns

Int the maximum number of toys you can purchase 

Constraints

1<=n<=10^5

1<=price[i]<=100

1<=money<=10^6

Sample case 

Sample input 0

7->n=7

1-> price[]=[1,4,5,3,2,1,6]

4

5

3

2

1

6

Sample Output

6 ->money=6

QUESTION : Formatting large Products

Rohan is weak in mathematics.He is giving mathematics  Olympiad , but he got stuck in one of the question .Help rohan to solve the question.In Question there are two positive integer A and B. You have to find the product of all integer between A and B which is represented in the form C=D*10^E , where  C is the product of numbers , D and E are non-negative integers and the last digit of D is non-zero.

Function Description 

Complete the function formatProducts in the editor below, formatProduct must return a string that represents C in the above described form.

Function has the following parameters

A: an integer

B: an integer

Constraints

  •    A will between 1 and 1,000,000 . Inclusive.
  •    B will be between A and 1,000,000. Inclusive.

Sample Input 0 

1

5

Sample Output 0

12 * 10^1

Explanation 

1*2*3*4*5=120 = 12 * 10^1

Sample Input 1

3

10

Sample Output 1

18144 * 10^2

Explanation

3*4*….*10=1814400 =18144 * 10^2

QUESTION : Copycat in exam (R->Medium)

Rahul copies in the exam from his adjacent students. But he doesn’t want to be caught, so he changes words keeping the letter constant. That means he interchanges the positions of letters in words. You are the examiner and you have to find if he has copied a certain word from the one adjacent student who is giving the same exam, and give Rahul the markings he deserves.

Note that: Uppercase and lowercase are the  same.

Input Format:

First line with the adjacent student’s word

Second line with Rahul’s word

Output Format:

0 if not copied

1 if copied

Constraints:

1<=Length of string<=10^6

Sample Input:

CAR

ACR

Sample Output:

1

QUESTION : Mr. Robot’s Password (R)

Mr. Robot is making a website, in which there is a tab to create a password. As other websites, there are rules so that the password gets complex and none can predict the password for another. So he gave some rules like:

– At least one numeric digit

– At Least one Small/Lowercase Letter

– At Least one Capital/Uppercase Letter

– Must not have space 

– Must not have slash (/)

– At least 6 characters

If someone inputs an invalid password, the code prints: “Invalid password, try again”.

Otherwise, it prints: “password valid”.

Input Format:

A line with a given string as a password

Output Format:

If someone inputs an invalid password, the code prints: “Invalid password, try again”.

Otherwise, it prints: “password valid”, without the quotation marks.

Constraints:

Number of character in the given string <=10^9

Sample input 1: 

abjnlL09

Sample output 1: 

password valid

Sample input 2: 

jjnaskpk

Sample output 2: 

Invalid password, try again

FAQs on PwC Coding Questions with Solutions

Question 1: Are there any coding questions asked in PwC?

Yes, for technical profiles PwC asks coding questions. On this page, we have provided all the PwC Coding Questions

Question 2: Is PwC exam difficult to crack?

PwC exam is definitely tricky. They put emphasis on analytical thinking and problem solving skills of the candidate.

Get over 200+ course One Subscription

Courses like AI/ML, Cloud Computing, Ethical Hacking, C, C++, Java, Python, DSA (All Languages), Competitive Coding (All Languages), TCS, Infosys, Wipro, Amazon, DBMS, SQL and others

Checkout list of all the video courses in PrepInsta Prime Subscription

Checkout list of all the video courses in PrepInsta Prime Subscription