InternDoor

PwC interview prep

8 practice questions on the topics candidates reported from PwC interviews, with answers. The questions are ours; each one links to the interview report that names its topic.

Practise them as a timed round9 roles open at PwC India

DSA 1

  1. DSAMedium

    How many subsequences of [1, 2, 3, 4] have elements adding up to 5?

    1. 1
    2. 3
    3. 4
    4. 2
    Show the answer

    D. 2

    Only {1, 4} and {2, 3} sum to 5. Each element is either taken or not, so there are 2^n subsequences to try; a DP over the sums counts them in O(n * K).

    This topic is named in a candidate’s interview report: Acceleration Center associate interview, 2022, on GeeksforGeeks.

Java 1

  1. JavaMedium

    What does this print?

    public class Main {
        static int f() {
            try {
                throw new RuntimeException("x");
            } catch (RuntimeException e) {
                System.out.print("catch ");
                return 1;
            } finally {
                System.out.print("finally ");
            }
        }
    
        public static void main(String[] args) {
            System.out.print(f());
        }
    }
    1. catch 1
    2. catch finally 1
    3. finally catch 1
    4. catch finally
    Show the answer

    B. catch finally 1

    The catch block runs and prepares to return 1, but finally always runs before the method actually returns. Only then does main print the returned value.

    This topic is named in a candidate’s interview report: Associate on-campus interview, 2020, on GeeksforGeeks.

DBMS and SQL 4

  1. DBMS and SQLHard

    What does this query return for each employee?

    SELECT name, dept, salary,
           AVG(salary) OVER (PARTITION BY dept) AS dept_avg
    FROM emp;
    1. One row per department with its average salary
    2. An error: AVG needs GROUP BY
    3. Every employee row, plus the average salary of all employees in the company
    4. Every employee row, plus the average salary of that employee's own department
    Show the answer

    D. Every employee row, plus the average salary of that employee's own department

    A window function computes over a partition without collapsing rows, unlike GROUP BY. Each row keeps its own columns and gains its department's average, which makes comparisons such as salary - dept_avg easy.

    This topic is named in a candidate’s interview report: Associate on-campus interview, 2020, on GeeksforGeeks.

  2. DBMS and SQLMedium

    What does adding an index on a column usually do?

    1. Speeds up queries that search or sort on that column, at the cost of extra storage and slower inserts and updates
    2. Speeds up every query on the table, with no cost
    3. Prevents duplicate values in the column
    4. Compresses the table to save space
    Show the answer

    A. Speeds up queries that search or sort on that column, at the cost of extra storage and slower inserts and updates

    A B-tree index lets the database find matching rows in O(log n) instead of scanning the table. Every write must also update the index, so indexes go on columns that are searched often. Only a UNIQUE index stops duplicates.

    This topic is named in a candidate’s interview report: Acceleration Center associate interview, 2022, on GeeksforGeeks.

  3. DBMS and SQLEasy

    What is a trigger in SQL?

    1. A query that runs on a schedule, such as every night
    2. Code the database runs automatically when a chosen event, such as an INSERT, UPDATE or DELETE on a table, happens
    3. A constraint that stops NULL values
    4. Another name for a stored procedure the user calls by hand
    Show the answer

    B. Code the database runs automatically when a chosen event, such as an INSERT, UPDATE or DELETE on a table, happens

    A trigger can run BEFORE or AFTER the event, for example to write an audit row whenever a salary changes. A stored procedure, by contrast, runs only when it is called.

    This topic is named in a candidate’s interview report: Acceleration Center associate interview, 2022, on GeeksforGeeks.

  4. DBMS and SQLMedium

    Which query lists the salary values that are shared by more than one employee?

    1. SELECT DISTINCT salary FROM emp;
    2. SELECT salary FROM emp WHERE COUNT(salary) > 1;
    3. SELECT salary FROM emp GROUP BY salary HAVING COUNT(*) > 1;
    4. SELECT salary FROM emp ORDER BY salary;
    Show the answer

    C. SELECT salary FROM emp GROUP BY salary HAVING COUNT(*) > 1;

    GROUP BY salary makes one group per distinct value and HAVING keeps the groups with more than one row. Adding ORDER BY COUNT(*) DESC LIMIT 3 would give the three most common salaries.

    This topic is named in a candidate’s interview report: Acceleration Center associate interview, 2022, on GeeksforGeeks.

Computer networks 1

  1. Computer networksMedium

    How does an intrusion prevention system (IPS) differ from an intrusion detection system (IDS)?

    1. An IPS sits in the traffic path and can block malicious traffic; an IDS watches a copy of the traffic and raises alerts
    2. An IDS blocks traffic; an IPS only logs it
    3. They are the same thing
    4. An IPS encrypts traffic and an IDS decrypts it
    Show the answer

    A. An IPS sits in the traffic path and can block malicious traffic; an IDS watches a copy of the traffic and raises alerts

    Detection is passive, so a false positive costs only an alert. Prevention is inline, so it can stop an attack as it happens, but a false positive drops legitimate traffic.

    This topic is named in a candidate’s interview report: Cybersecurity consultant on-campus interview, 2021, on GeeksforGeeks.

Aptitude 1

  1. AptitudeHard

    There are 10 stacks of 10 coins. Every coin weighs 10 g except in one stack, where every coin weighs 11 g. With one reading of a digital scale, how do you find that stack?

    1. Weigh one coin from each stack together
    2. Weigh stacks 1 to 5 against stacks 6 to 10
    3. It cannot be done in one weighing
    4. Take 1 coin from stack 1, 2 from stack 2, and so on up to 10 from stack 10, weigh them all: the grams over 550 give the stack number
    Show the answer

    D. Take 1 coin from stack 1, 2 from stack 2, and so on up to 10 from stack 10, weigh them all: the grams over 550 give the stack number

    55 coins would weigh 550 g if all were 10 g. Each coin from the heavy stack adds 1 g, and stack k contributed k coins, so a reading of 557 g means stack 7.

    This topic is named in a candidate’s interview report: Associate on-campus interview, 2020, on GeeksforGeeks.

Prep for other employers

All employers
See who is hiring after PwC

Engineering internships and entry-level jobs in India, newest first.