Monthly Archives: May 2013

Given two strings as an input for a function, return true if one string is a permutation of another

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Collections; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { string str1 = "aabbcdeffaa"; string str2 = "fabafbcadae"; Console.WriteLine(IsPermutation(str1, str2)); } public static bool IsPermutation(string str1, string str2) { … Continue reading

Posted in Information Technology | Leave a comment

Rotate a square matrix by 90 degrees clockwise

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

Posted in Information Technology | Leave a comment

Given a binary tree replace all the node values with the sum of all its children values added to the current node value

       Input tree:                                Output tree: using System; using System.Collections.Generic; using System.Collections; using System.Linq; using System.Text; namespace ConsoleApplication3 { public class Node { private Node left; private Node right; private int _value; public Node(Node left, Node right, int value) { this.left = … Continue reading

Posted in Information Technology | Leave a comment