Given a string of lowercase characters, reorder them such that the same characters are at least distance d from each other.

# Category Archives: Uncategorized

# Printing Matrix (2D array) in Spiral Order

Given a matrix (2D array) of m x n elements (m rows, n columns), write a function that prints the elements in the array in a spiral manner.

# Finding prime numbers

Output all prime numbers up to a specified integer n.

# Binary Search Tree In-Order Traversal Iterative Solution

Given a binary search tree, print the elements in-order iteratively without using recursion.

# Hacking a Google interview (From MIT)

Google interview is so popular that even MIT dedicates a course to it! » Hacking a Google Interview Course Website

# Rotating an array in place

Rotate a one-dimensional array of n elements to the right by k steps. For instance, with n=7 and k=3, the array {a, b, c, d, e, f, g} is rotated to {e, f, g, a, b, c, d}.

# Searching an Element in a Rotated Sorted Array

Suppose a sorted array is rotated at some pivot unknown to you beforehand. (i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2). How do you find an element in the rotated array efficiently? You may assume no duplicate exists in the array.

# Finding all unique triplets that sums to zero

Given a set S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the set which gives the sum of zero.

# How to determine if a point is inside a rectangle?

Given a 2D point and a rectangle, determine if the point is inside the rectangle.

# Reversing linked list iteratively and recursively

Implement the reversal of a singly linked list iteratively and recursively.

# Recursion to the rescue!

Given only putchar (no sprintf, itoa, etc.) write a routine putlong that prints out an unsigned long in decimal.

# C code to count the number of words in a string

Count the number of words in a string, where a word is defined to be a contiguous sequence of non-space characters.

# C code to remove spaces from a string

Write a C function to remove spaces from a string. The function header should be void removeSpaces(char *str)

# Interview tips for programmers

If you are majoring in Computer Science, chances are you’ll be working with jobs that require some degree of programming. When you’re looking for a job in the market, you’ll be having a lot of interviews. Interviewer loves to challenge you by asking some technical interview questions.