# Category Archives: Logical Problems

# Binary Search

# Frog Jump through leaves problem

Problem: A small frog wants to get to the other side of a river. The frog is currently located at position 0, and wants to get to position X. Leaves fall from a tree onto the surface of the river. You are given a non-empty zero-indexed array A consisting of N integers representing the falling Continue Reading…

# Passing car problem

Problem: A non-empty zero-indexed array A consisting of N integers is given. The consecutive elements of array A represent consecutive cars on a road. Array A contains only 0s and/or 1s: 0 represents a car traveling east, 1 represents a car traveling west. The goal is to count passing cars. We say that a pair Continue Reading…

# Frog Problem: Count minimal number of jumps from position X to Y.

Problem: A small frog wants to get to the other side of the road. The frog is currently located at position X and wants to get to a position greater than or equal to Y. The small frog always jumps a fixed distance, D. Count the minimal number of jumps that the small frog must Continue Reading…

# Remove duplicate element of an integer array

Problem: Remove duplicate element of an integer array. Solution:

# Number of factors of a number

Problem: Find the number of factors of a given number. eg. The number of factors of 10 are (2,5,10) = 3 The number of factors of 18 are (2,3,6,9,18) = 5 Solution:

# Find Mirror image of the string

Problem: Find Mirror image of the string: like for name “arora”, “o” is the mirror image of arora. Solution:

# Brackets Nested Problem

Problem: A string S consisting of N characters is called properly nested if: S is empty; S has the form “(U)” where U is a properly nested string; S has the form “VW” where V and W are properly nested strings. For example, string “(()(())())” is properly nested but string “())” isn’t. Write a function: Continue Reading…

# Brackets Problem(Determine whether a given string of parentheses is properly nested)

Problem: A string S consisting of N characters is considered to be properly nested if any of the following conditions is true: S is empty; S has the form “(U)” or “[U]” or “{U}” where U is a properly nested string; S has the form “VW” where V and W are properly nested strings. For Continue Reading…