Monthly Archives: November 2015

Find the smallest window within an array that contains all the elements of another array

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Collections; using System.Diagnostics; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { int[] array1 = { 6, 7, 1, 3, 2, 4, 5, 2, 3, 1, 2, 5 }; … Continue reading

Posted in Information Technology | Leave a comment

Given a binary matrix, find the row with max decimal value

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Collections; using System.Diagnostics; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { int[,] binaryMatrix = new int[,] { { 0, 1, 0 }, { 1, 1, 0 }, { … Continue reading

Posted in Information Technology | Leave a comment

Count the specified digit occurrence between 0 and the given number

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Collections; using System.Diagnostics; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { Console.WriteLine(CountDigitOccurrence(1000000, 2)); } public static int CountDigitOccurrence(int number, int digit) { int count = 0; for (int … Continue reading

Posted in Information Technology | Leave a comment

Editing excel files using Java

import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.util.Iterator; import java.util.concurrent.TimeUnit; import org.openqa.selenium.*; import org.openqa.selenium.firefox.FirefoxDriver; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.CellStyle; import org.apache.poi.ss.usermodel.IndexedColors; import org.apache.poi.ss.usermodel.Row; import org.apache.poi.xssf.usermodel.XSSFCellStyle; import org.apache.poi.xssf.usermodel.XSSFSheet; import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.jsoup.Jsoup; import org.jsoup.nodes.Document; import org.jsoup.nodes.Element; import org.jsoup.select.Elements; public class Test { … Continue reading

Posted in Information Technology | Leave a comment

Fill two instances of all numbers from 1 to n in a specific way

Given a number n, create an array of size 2n such that the array contains 2 instances of every number from 1 to n, and the number of elements between two instances of a number i is equal to i. … Continue reading

Posted in Information Technology | Leave a comment

Count number of ways to cover a distance

Given a distance ‘dist’, count total number of ways to cover the distance with 1, 2 and 3 steps. Examples: Input: n = 3 Output: 4 Below are the four ways 1 step + 1 step + 1 step 1 … Continue reading

Posted in Information Technology | Leave a comment

Find maximum of minimum for every window size in a given array

Given an integer array of size n, find the maximum of the minimum’s of every window size in the array. Note that window size varies from 1 to n. Examples: Input: arr[] = {10, 20, 30, 50, 10, 70, 30} … Continue reading

Posted in Information Technology | Leave a comment