Code Samurai

A Practice Ground for Programmers

▼
Thursday, August 18, 2011

Difference Between Sums of Odd and Even Levels in Binary Trees

›
Question: calculate the difference between the sum of nodes at even level and sum of nodes at odd level. Solution: recursion is the easi...
3 comments:
Friday, July 29, 2011

How to Reverse a String

›
Question: given a string, reverse it. You can destroy the original string or return a new string that is the reverse of the original string...
1 comment:
Friday, July 8, 2011

Minimum Distance Between Two Elements in an Array

›
Question: given an array and two elements, find the minimum distance between the elements in the array. The array may have duplicates. For ...
2 comments:
Friday, July 1, 2011

Convert Binary Tree to Double Linked List in Zig-Zag Order

›
Question: given a binary tree, write an algorithm to convert the tree into a double-linked list. The list must be as if the tree is travers...
Tuesday, June 28, 2011

Check If an Integer's Bit Representation Is a Palindrome

›
Question: how can you determine if a positive integer is a palindrome. For example, 5 is a palindrome because 5 = 101. Also, 9 is a palindr...
5 comments:
›
Home
View web version
Powered by Blogger.