0% found this document useful (0 votes)
2 views7 pages

CodeStore 3 Question Test Prep With Code

This document provides a structured test preparation guide for a coding interview, focusing on 2 DSA questions and 1 web/mobile question. It includes probable questions, detailed explanations, and code examples for algorithms and web development concepts, emphasizing understanding logic over memorization. Additionally, it offers a revision plan and tips for effectively communicating answers during the interview.

Uploaded by

hero187104
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views7 pages

CodeStore 3 Question Test Prep With Code

This document provides a structured test preparation guide for a coding interview, focusing on 2 DSA questions and 1 web/mobile question. It includes probable questions, detailed explanations, and code examples for algorithms and web development concepts, emphasizing understanding logic over memorization. Additionally, it offers a revision plan and tips for effectively communicating answers during the interview.

Uploaded by

hero187104
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

CodeStore Technologies

3-Question Test Prep with Python Code


Focused for 2 DSA questions + 1 Web/Mobile question in 60 minutes

Built from your placement notice and the uploaded prep list.

How to use this document


 First read the pattern of the question, then the idea, then the code.
 Do not memorize only the code. Learn the logic so you can change it in the exam.
 For every coding answer, remember three things: idea, time complexity, and how to explain it in 20 seconds.
 For the web question, practice saying the code out loud like you are teaching it to someone else.

What is most likely in the 60-minute test


Your placement notice says the first round has 3 questions: 2 from Algorithms and 1 from Web/Mobile Development.
Public reports also suggest questions like array logic, pattern printing, API fetch, and simple web basics.

Note: This is why the document focuses on arrays, strings, logic, and one complete web demo you can
actually understand.

Top 12 most probable practice questions


 Reverse an array in place.
 Find the second largest element in an array.
 Count frequency of each element.
 Find the missing number from 1 to n.
 Check whether a string is a palindrome.
 Check balanced parentheses.
 Print a star pattern.
 Print a number pyramid.
 Explain HTML, CSS, and JavaScript.
 What is the DOM?
 Write code to fetch data from an API and display it.
 Explain the difference between GET and POST.

Part 1: DSA questions with full Python code and simple explanation

1) Reverse an array in place


Idea: Use two pointers: one at the start and one at the end. Swap them, then move inward.
Complexity: Time: O(n) | Space: O(1)

def reverse_array(arr):
left = 0
right = len(arr) - 1

while left < right:


arr[left], arr[right] = arr[right], arr[left]
left += 1
right -= 1

return arr

arr = [1, 2, 3, 4, 5]
print(reverse_array(arr))

How to understand it:


 Think of two people standing at both ends of a line and swapping places until they meet in the middle.
 We do not create a new array, so memory use stays low.
 This is a very common interview pattern.

2) Find the second largest element


Idea: Track the largest and second largest while scanning once.
Complexity: Time: O(n) | Space: O(1)

def second_largest(arr):
if len(arr) < 2:
return None

first = second = float('-inf')

for num in arr:


if num > first:
second = first
first = num
elif first > num > second:
second = num

return None if second == float('-inf') else second

arr = [10, 5, 8, 20, 20, 3]


print(second_largest(arr))

How to understand it:


 Imagine two winners on a podium: first place and second place.
 Every new number can either take first place or become second place.
 We ignore duplicates of the largest value unless a smaller valid second largest exists.

3) Count frequency of each element


Idea: Use a dictionary to store how many times each number appears.
Complexity: Time: O(n) | Space: O(n)

def count_frequency(arr):
freq = {}

for num in arr:


freq[num] = [Link](num, 0) + 1
return freq

arr = [1, 2, 2, 3, 1, 4, 2]
print(count_frequency(arr))

How to understand it:


 Each time we see a number, we increase its count by 1.
 A dictionary is perfect here because it acts like a fast lookup table.
 This is the base idea behind many interview counting problems.

4) Find the missing number from 1 to n


Idea: Use the formula n(n+1)/2 and subtract the actual sum.
Complexity: Time: O(n) | Space: O(1)

def missing_number(arr, n):


expected_sum = n * (n + 1) // 2
actual_sum = sum(arr)
return expected_sum - actual_sum

arr = [1, 2, 4, 5]
n = 5
print(missing_number(arr, n))

How to understand it:


 If 1 to 5 should be present, the total should be 15.
 If the array sums to 12, then the missing number is 3.
 This is a clean math trick and very common in tests.

5) Check whether a string is a palindrome


Idea: Compare the string with its reverse or use two pointers.
Complexity: Time: O(n) | Space: O(1) or O(n) if using slicing

def is_palindrome(s):
left = 0
right = len(s) - 1

while left < right:


if s[left] != s[right]:
return False
left += 1
right -= 1

return True

print(is_palindrome("madam"))
print(is_palindrome("hello"))

How to understand it:


 A palindrome reads the same from left to right and right to left.
 Two pointers let us check both ends at the same time.
 This is better than creating a reversed copy in memory.
6) Check balanced parentheses
Idea: Use a stack. Push opening brackets, pop when closing brackets match.
Complexity: Time: O(n) | Space: O(n)

def is_balanced(expr):
stack = []
pairs = {')': '(', ']': '[', '}': '{'}

for ch in expr:
if ch in '([{':
[Link](ch)
elif ch in ')]}':
if not stack or stack[-1] != pairs[ch]:
return False
[Link]()

return len(stack) == 0

print(is_balanced("({[]})"))
print(is_balanced("({[})"))

How to understand it:


 Think of a stack of plates: the last opening bracket must be the first one closed.
 If the closing bracket does not match the top of the stack, the expression is invalid.
 This question is a classic because it tests stack thinking.

More DSA answers you should know in short form


 Rotate an array by k positions: Use slicing or reverse sections. Time O(n), Space O(1) with reverse trick.
 Check if array is sorted: Scan once and compare adjacent elements. Time O(n), Space O(1).
 Find pairs with a given sum: Use a set or two pointers if sorted. Time O(n) or O(n log n).
 Maximum subarray sum: Use Kadane's algorithm. Keep current sum and best sum.
 Binary search: Only works on sorted arrays. Keep halving the search space. Time O(log n).

Part 2: Web question with full code and beginner-friendly explanation


The most likely web question is: write code to fetch data from an API and display it on the page.
You should understand it in three layers: HTML gives structure, CSS gives looks, and JavaScript gives behavior.

Full working example: API fetch and display


This example calls a public API and shows the data on the screen.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Fetch API Example</title>
<style>
body {
font-family: Arial, sans-serif;
background: #f5f7fb;
margin: 0;
padding: 30px;
}
.container {
max-width: 800px;
margin: auto;
background: white;
padding: 20px;
border-radius: 12px;
box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}
button {
padding: 10px 16px;
border: none;
background: #1f4e79;
color: white;
border-radius: 8px;
cursor: pointer;
margin-bottom: 16px;
}
.card {
background: #eef4ff;
padding: 12px 14px;
border-radius: 10px;
margin-bottom: 10px;
}
.title {
font-weight: bold;
margin-bottom: 4px;
}
</style>
</head>
<body>
<div class="container">
<h1>Users List</h1>
<button onclick="loadUsers()">Load Users</button>
<div id="output"></div>
</div>

<script>
async function loadUsers() {
const output = [Link]("output");
[Link] = "Loading...";

try {
const response = await fetch("[Link]
const data = await [Link]();

[Link] = "";
[Link](user => {
const div = [Link]("div");
[Link] = "card";
[Link] = `
<div class="title">${[Link]}</div>
<div>Email: ${[Link]}</div>
<div>City: ${[Link]}</div>
`;
[Link](div);
});
} catch (error) {
[Link] = "Error loading users.";
[Link](error);
}
}
</script>
</body>
</html>
How this code works
 HTML creates the page layout: heading, button, and output area.
 CSS makes the page cleaner and easier to read.
 JavaScript waits for the button click, calls fetch(), reads JSON, and shows the results.
 async and await make the code easier to read because the API call looks like normal step-by-step code.
 try/catch is used so the app does not crash if the API fails.
Note: If they ask only theory, say: HTML structures content, CSS styles it, and JavaScript adds
interactivity. DOM means the page elements JavaScript can control.

Mini React version for extra confidence


If they ask React basics, this small example helps you explain state, useEffect, and rendering.

import React, { useEffect, useState } from "react";

export default function UsersList() {


const [users, setUsers] = useState([]);
const [loading, setLoading] = useState(true);

useEffect(() => {
async function fetchUsers() {
try {
const response = await fetch("[Link]
const data = await [Link]();
setUsers(data);
} catch (error) {
[Link]("Failed to fetch users:", error);
} finally {
setLoading(false);
}
}

fetchUsers();
}, []);

if (loading) {
return <p>Loading users...</p>;
}

return (
<div>
<h2>Users</h2>
{[Link]((user) => (
<div key={[Link]}>
<strong>{[Link]}</strong> - {[Link]}
</div>
))}
</div>
);
}

How to explain the React example


 useState stores data inside the component.
 useEffect runs the fetch once when the component loads.
 setUsers saves the API result into state.
 map() renders one card for each user.
Part 3: Fast theory answers for the same test
What is the DOM? The DOM is the tree-like structure of the web page. JavaScript can read and change it.
What is REST API? REST API is a way for apps to talk over HTTP using actions like GET, POST, PUT, and DELETE.
Difference between GET and POST GET reads data, POST sends data to create something new.
Difference between let, var, and const let can change, var is old and function-scoped, const cannot be reassigned.
What is asynchronous programming? It means the program can do other work while waiting for something slow like an
API.

Part 4: Short answers for non-code questions


Tell me about yourself Start with your name, branch, project, strongest skill, and why you are applying.
Why do you want this role? Say you want a real software role, learning opportunity, and a chance to work on practical
development.
Are you willing to relocate to Noida? Answer honestly and clearly.
Why should we select you? Say you are eager to learn, can solve problems, and will give consistent effort.

Last 15-minute revision plan


 Reverse array and second largest.
 Palindrome and balanced brackets.
 Missing number and frequency count.
 Fetch API code.
 HTML, CSS, JavaScript, DOM, GET vs POST.
Note: The goal is not to memorize everything. The goal is to recognize the pattern immediately and write
a correct, simple solution under pressure.

You might also like