Showing 12 questions
Simulate a box tilting to the right, causing stones to fall until they hit obstacles or the floor. Re-arrange the characters in a given grid to reflect the resulting state of the box.
#1. Rotating the Box
Imagine a squirrel trying to collect nuts efficiently. Find the minimum distance the squirrel must travel to collect all nuts and bring them to a tree, given the locations of the squirrel, tree, and nuts.
#2. Squirrel Simulation
Determine if a given string can be segmented into a space-separated sequence of words from a dictionary. You are given a string and a dictionary of words; can you break the string down using words from the dictionary?
#3. Word Break
You're given an array of numbers. Find how many pairs of numbers in the array satisfy a specific 'nice' property determined by reversing their digits and comparing them.
#4. Count Nice Pairs in an Array
Simulate a robot moving around a rectangular grid, following specific movement rules and boundary conditions. You need to implement the robot's movement and track its position and direction after each step.
#5. Walking Robot Simulation II
Given an array, sort it using pancake flips. Each flip reverses a portion of the array; find the sequence of flips to sort the array.
#6. Pancake Sorting
Imagine dropping squares of varying sizes onto a number line. Calculate the height of the tallest stack of squares after each drop.
#7. Falling Squares
On a chessboard, find how many pawns a rook can capture in one move. The rook can move horizontally or vertically until it hits an obstacle or the edge of the board.
#8. Available Captures for Rook
Imagine a grid where some 2x2 blocks are marked. Count how many unique integers from 0 to 4 (inclusive) represent the number of marked cells within those 2x2 blocks that intersect with given coordinates.
#9. Number of Black Blocks
Design a data structure that efficiently stores a set of strings and allows for prefix-based searches. Implement methods to insert strings, search for complete words, and check if any word starts with a given prefix.
#10. Implement Trie (Prefix Tree)
Simulate the basic operations of a text editor. Implement functions to add text, delete characters, and move the cursor.
#11. Design a Text Editor
You're given a maze represented by a matrix, and a starting point. Determine if it's possible to reach the maze's destination by rolling a ball through open spaces.
#12. The Maze