Swap variables interview question

Swapping two variables without a temp Given two integer variables A and B. Write C++ code to swap them without using a temporary variable. Solution This is a well known problem for which you can find so many references on …

Read more »

Palindrome string program in C

Problem Write a C++ algorithm that takes a string as input then check if the input string is Palindrome. A Palindrome string reads the same from left to right and from right to left as in the following example: Rats …

Read more »

Reverse string in c++

Problem A typical interview question is to describe an algorithm to reverse a string of characters. Solution We need one pass through the characters of the string to get the string length or use a built in function to get …

Read more »

Number of Iterations

Problem If you run the following block of java code. How many times the print statement is going to execute. public class Counting { public static void main(String[] args)   {   for (int i = 0; i < 100; …

Read more »

Sql relational division example

Problem Given the following database tables Employee (SSN, name, location) Assigned (SSN, project_name, duration) Project (project_name, category, budget, location) Write SQL statements to find the following: Project names with a budget smaller than the average budget of projects in a …

Read more »

Character count in string Java

Problem Write a Java program to find character counts in a string consisting from capital letters (A to Z) only. The program must not use nested loops. Hash tables that are built in to the language must not be used …

Read more »

3 Ants Triangle Puzzle

Triangle ants problem Three ants on the corners of an equilateral triangle. They started moving along the edges at the same speed. What is the probability that the ants will collide ? Solution Each ant could possibly be moving in …

Read more »

Page 29 of 30« First...1020...2627282930