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

Coding Challenge May

The document contains 25 coding statements, each describing a unique programming challenge along with test cases and expected outputs. Examples include counting direction switches in an array, simulating infection spread in a matrix, and validating Sudoku diagonals. Each statement provides a specific problem to solve, showcasing a variety of algorithmic concepts.

Uploaded by

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

Coding Challenge May

The document contains 25 coding statements, each describing a unique programming challenge along with test cases and expected outputs. Examples include counting direction switches in an array, simulating infection spread in a matrix, and validating Sudoku diagonals. Each statement provides a specific problem to solve, showcasing a variety of algorithmic concepts.

Uploaded by

Prasad Sangitrao
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Coding Statement 1:.

Trend Turn Counter


Count how many times the direction of values in an array switches
(increasing to decreasing or vice versa).
Test Case: [1, 2, 3, 2, 1, 4]
Output: 2
---------------------------------------------------------------------------------------
Coding Statement 2:. Infection Spread Clockwise
Infect cells in a matrix starting from the top-left and spiraling outward.
Return time (in steps) to infect all.
Test Case:
[[1, 0, 0],
[0, 0, 0],
[0, 0, 0]]

Output: 4
----------------------------------------------------------------------------------------
Coding Statement 3: Circular Character Shift
You are given a string and an integer `k`. Shift each character forward by
`k` positions in the alphabet, wrapping around (‘z’ → ‘a’). Ignore spaces.
Test Case: `"abc xyz", k=2
Output: "cde zab"`
-----------------------------------------------------------------------------------

Coding Statement 4:. Compressed Storage Expansion

Page 1 of 7
A string contains letters followed by numbers (e.g., "a2b3"). Expand the
string to repeat characters by their count.
Test Case: `"a2b3"
Output: "aabbb"`

-------------------------------------------------------------------------------------
Coding Statement 5:. Maximum XOR Subarray
Find the subarray with the maximum XOR value in a given array of
integers.
Test Case: `[3, 10, 5, 25, 2, 8]
Output: 28`

-----------------------------------------------------------------------------------------
Coding Statement 6: Brick Jump Game
Each brick has a number representing how far you can jump. Can you
reach the end?
Test Case: `[2,3,1,1,4]
Output: True`
-----------------------------------------------------------------------------------------
Coding Statement 7:. Smoothie Sort
Given a string of lowercase letters, sort only the vowels while keeping
consonants in place.
Test Case: `"programming"
Output: "prigrammong"`

-----------------------------------------------------------------------------------------

Page 2 of 7
Coding Statement 8:. Sudoku Diagonal Validator
Validate if both the main and anti-diagonals of a Sudoku board have
unique values (excluding 0).
Test Case: Custom 9x9 input
-----------------------------------------------------------------------------------
Coding Statement 9 : Spy Message Decoder
Every even-indexed letter in a message is encoded with +2 shift, odd with
-1. Decode the message.
Test Case: `"cdbq"
Output: "beat"`

------------------------------------------------------------------------------------
Coding Statement 10:. Subsequence Pair Matcher
Find all pairs of substrings from two strings where one is a subsequence
of the other.
Test Case: `"abc", "acbd" → [("ab", "acbd"), ("abc", "acbd")]`

-----------------------------------------------------------------------------------------
Coding Statement 11:. Checkout Queue Optimizer
You have `n` cash counters. Distribute a list of customer processing times
to minimize total queue time.
Test Case: `counters = 2, times = [5, 3, 4] → [5+4, 3] → 9`

-----------------------------------------------------------------------------------------

Page 3 of 7
Coding Statement 12. Tunnel Navigator
Navigate from point A to B in a matrix, but tunnels allow instant travel
between specific cells.
Test Case: `(0,0) → (2,2)` with tunnel: (1,0) ↔ (2,2)
-----------------------------------------------------------------------------------
Coding Statement 13 : Juice Mixing Ratio
You’re given containers of juice with different ratios of sugar to water.
Find the mixture closest to a target ratio.
Test Case: `[(3,7), (5,5), (6,4)], target = (4,6) → (5,5)`

-----------------------------------------------------------------------------------------
Coding Statement 14: Virus Containment Zones
Determine the minimum number of walls needed to block a virus from
spreading in a matrix.
Test Case: Grid with 1s (infected), 0s (clean),
output = 4

-----------------------------------------------------------------------------------------
Coding Statement 15:. Shifting Clock Hands
Simulate the positions of clock hands after a certain number of ticks.
Output angle between them.
Test Case: `Ticks = 15 minutes → 82.5 degrees`
----------------------------------------------------------------------------------------

Coding Statement 16:. ID Generator with History

Page 4 of 7
Design a system that generates unique IDs and never repeats any ID that
was used in the last `k` generations.
Test Case: Generate 7 IDs with `k=3`, avoid 3-history repeat.
-----------------------------------------------------------------------------------------
Coding Statement 17.: Red Light Tracker
Given car positions and traffic light timings, determine how many cars
will stop at red lights.
Test Case: Cars = `[0, 5, 10]`,
Light at 5s intervals
Output: 1
----------------------------------------------------------------------------------------
Coding Statement 18. Water Level Prediction
Given an elevation map and hourly rainfall, simulate rising water levels
and predict overflow points.
Test Case: Elevation `[3,1,2,4]`,
rain = 2hr
Output: Overflows at index 1
----------------------------------------------------------------------------------------
Coding Statement 19. Lucky Slot Machine Sequence
Simulate a slot machine and find how often the winning sequence appears
in a given sequence of spins.
Test Case:
Spins = `["777", "123", "777", "777"]`,
winning = "777"
Output: 3
-----------------------------------------------------------------------------------

Page 5 of 7
Coding Statement 20:. City Route Detour
Find the shortest path from city A to B but skip a specific blocked road.
Test Case: Road blocked: (2 → 3),
Graph: A → 2 → 3 → B →
Output: A → 4 → 3 → B
-----------------------------------------------------------------------------------------
Coding Statement 21. Dictionary Tree Expansion
You’re given a compressed dictionary with shared prefixes. Expand it
into all full words.
Test Case:
`{“app”: [“le”, “end”]}`
Output: `["apple", "append"]`

Coding Statement 22:. Loop Dependency Sort


Sort a list of tasks with dependencies. If there's a circular dependency,
report the loop.
🔍 Test Case:
`A → B → C → A → Loop`
--------------------------------------------------------------------------------------
Coding Statement 23:. Game Map Territory Split
Given a grid-based game map with multiple players, return number of
unique territories controlled.
Test Case:
Grid with marked zones
Output: 4
---------------------------------------------------------------------------------------

Page 6 of 7
Coding Statement 24:. Longest Valid Command Chain
From a list of system commands, find the longest chain where each
command depends on the previous.
Test Case:
`[“init”, “load”, “load-data”, “run”] →
Output: 3`

-----------------------------------------------------------------------------------------
Coding Statement 25:. Smart Bulb Pattern Match
Bulbs flash in a sequence of 0/1. Check if a given binary pattern repeats
within a tolerance of 1 mismatch.
Test Case:
Bulbs = `[1,0,1,0,1,1]`,
Pattern = `[1,0,1]`

Output: 2 matches

Page 7 of 7

You might also like