Question bank / Freshers (India), Coding, Foundation
How to answer: Write a program to check whether a string is a palindrome.
Whether you can write a simple correct program and think of edge cases.
What the interviewer is testing.
Simple approach, edge cases and complexity. Whether you can write a simple correct program and think of edge cases.
An outline for this question.
- Ask whether case and spaces should be ignored.
- Use two pointers from both ends, comparing characters and moving inwards.
- State the cost: O(n) time and O(1) extra space.
- Test an empty string, one character, and an even and odd length string.
The mistake to avoid.
Reversing the whole string and comparing. It works but uses extra space, and the two pointer approach shows more skill.
The general method: clarify, plan, code, test.
The same shape works for most coding questions, whatever the topic.
- Restate the problem and ask about inputs, size limits and edge cases before you write anything.
- Describe your approach and its complexity out loud, then check it makes sense with the interviewer.
- Write clean code in small steps, narrating as you go.
- Walk through a normal case and an edge case by hand, then say what you would test.
Practice it, out loud.
Reading an outline is not the same as saying it. Answer this question in a mock interview, in your own words, then compare it with the outline above.
More to practice.
Given a string, return the first non-repeating character and explain the complexity.
Software Engineering, Coding
Design an LRU cache with O(1) get and put operations.
Software Engineering, Coding
Write SQL to calculate seven-day retention by signup cohort.
Data, Coding
Given a dependency graph, return a valid build order or explain why none exists.
Software Engineering, Coding
This is a Replysis practice question. It is not a leaked or official question from any company, and the outline is a guide to structure, not a script. Use your own experience and facts.