Monthly Archives: January 2012

Determining the longest palindrome in a given string

using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { //Determining the longest palindrome string str = "forgeeksskeegfor"; int flag = 0; for (int i = str.Length; i >= 1; i–) … Continue reading

Posted in Information Technology | Leave a comment

Find Next Higher Number With Same Digits

using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication1 {     class Program     {         static void Main(string[] args)         {             int num = 37723971;             string numStr = num.ToString();             for (int i = numStr.Length – … Continue reading

Posted in Information Technology | Leave a comment

Door State Toggling Problem

There are 100 doors initially kept in closed state. One has to go through 100 iterations and in each iteration, he has to toggle a certain set of doors given by the rule below: In ‘i’th numbered iteration, he has … Continue reading

Posted in Information Technology | Leave a comment

Lucky Sum

Chef loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Chef also use … Continue reading

Posted in Information Technology | Leave a comment

Printing all combinations using binary approach

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Net; using System.Runtime.InteropServices; using System.Collections; namespace ConsoleApplication1 {     class Program     {         static void Main(string[] args)         {             //Printing all combinations/power set using binary approach             char[] charArray … Continue reading

Posted in Information Technology | Leave a comment

Camel and Banana Puzzle

A camel is sitting by a stack of 3000 bananas at edge of a 1000 mile wide desert. He is going to travel across the desert carrying as many bananas as he can to the other sides. He can carry … Continue reading

Posted in Information Technology | Leave a comment

Given two ropes (with non-uniform composition) which take 1hr each to burn, how will you calculate 45 minutes?

Ignite Rope-A from both ends and Rope-B from one end. Rope-A will completely burn in 30 minutes (because it is put on fire from both ends). When Rope-A is burnt completely, Rope-B would have burnt for 30 minutes (it does … Continue reading

Posted in Information Technology | Leave a comment