Magic Square – IEEXtreme 8.0

Problem Johnny designed a magic square (square of numbers with the same sum for all rows, columns and diagonals i.e. both the main diagonal - meaning the diagonal that leads from the top-left corner towards bottom-right corner - and the antidiagonal - meaning the diagonal that leads from top-right corner towards bottom-left corner). Write a … Continue reading Magic Square – IEEXtreme 8.0

Sum It Up – IEEXtreme 8.0

Problem Minka is very smart kid who recently started learning computer programming. His coach gave him a cyclic array A having N numbers, and he has to perform Q operations on this array. In each operation the coach would provide him with a number X. After each operation, every element of the cyclic array would … Continue reading Sum It Up – IEEXtreme 8.0

Back to Square 1 – IEEEXtreme 8.0

The game “Back to Square 1” is played on a board that has n squares in a row and n-1 probabilities. Players take turns playing. On their first turn, a player advances to square 1.After the first turn, if a player is on square i , the player advances to square i + 1 with … Continue reading Back to Square 1 – IEEEXtreme 8.0

Reverse Words in a String

Reversing words in a string is a popular coding interview question. Here what is meant by reversing words in a string is something like this. Input string:     "My name is rajind and i am a believer" Output string:  "believer a am i and rajind is name My" Doing this in-place without use additional space … Continue reading Reverse Words in a String

Block Art – IEEEXtreme 9.0

Problem Statement The NeoCubist artistic movement has a very distinctive approach to art. It starts with a rectangle which is divided into a number of squares. Then multiple rounds of layering and scraping occur. In a layering round, a rectangular region of this canvas is selected and a layer of cubes, 1 cube deep, is … Continue reading Block Art – IEEEXtreme 9.0

Digit Fun! – IEEEXtreme 9.0

Problem Statement Recurrence relations are an important tool for the computer scientist. Many algorithms, particularly those that use divide and conquer, have time complexities best modeled by recurrence relations. A recurrence relation allows us to recursively define a sequence of values by defining the nth value in terms of certain of its predecessors. Many natural … Continue reading Digit Fun! – IEEEXtreme 9.0

Introduction to Algorithms (CLRS) Solutions Collection

This is a collection of solutions which I put together from various University course websites for the Introduction to Algorithms CLRS. It is not in any order but you could search for the question number and find what you want. Hope this might be useful to you all as it was helpful for me. Cheers! … Continue reading Introduction to Algorithms (CLRS) Solutions Collection

Cookie Clicker Alpha – Problem B – Google Code Jam 2014 Qualification Round

Introduction (Link to Question Page in Code Jam Website) Cookie Clicker is a Javascript game by Orteil, where players click on a picture of a giant cookie. Clicking on the giant cookie gives them cookies. They can spend those cookies to buy buildings. Those buildings help them get even more cookies. Like this problem, the … Continue reading Cookie Clicker Alpha – Problem B – Google Code Jam 2014 Qualification Round

Magic Trick – Problem A – Google Code Jam 2014 Qualification Round

Problem (Link to Question Page in Code Jam Website) Recently you went to a magic show. You were very impressed by one of the tricks, so you decided to try to figure out the secret behind it! The magician starts by arranging 16 cards in a square grid: 4 rows of cards, with 4 cards … Continue reading Magic Trick – Problem A – Google Code Jam 2014 Qualification Round