Basic Coding

The following are some basic coding exercises. These are not the brain-teaser/data structure/algorithm coding challenges that you probably will face in your interview but cover all of the basics of any programming language. As mentioned in the github repo, don’t use an IDE and start from scratch. Write a program that will:

  • Reverse a string
  • Print the sum of ints in a file one line at a time
  • Print out a multiplication table
  • Determine if a number is a power of two
  • Determine if a number is a twos compliment
  • Write code that will result in a deadlock. fix it
  • Find duplicate numbers in an array
  • Parse a String representation of a number into an int or float
  • Pack an IPV4 address into an int (or long in Java)
  • Write a method which will remove any given character from a String

  • Check if a string is a palindrome
  • Check if a string is an anagram of another string
  • Check if a positive int is a bit palindrome
  • read file line by line (and char, by char)
  • convert 3 8 bit numbers (RGB) to hex
  • capitalize the first letter of a sentence given a para of text
  • convert decimals to binary
  • rotate a multi-dimensional array
  • reverse a number

(Move this, to algorithm pages or get rid of it altogether)

Dynamic Programming Problems

  • Print the nth Fibonnaci number
  • Grid Traveler: How many ways can you travel through a n x m grid? Given a 2D grid of n x m size, and that you begin in the top left corner of the grid, how many ways can you travel to the bottom-right corner with the constraint that you can only move down and to the right?
  • Can Sum, or the Coin Counting problem: Given a target number and an array of numbers, potentially coins, return a boolean to indicate whether or not the target number can be made by the sum of any combination of the numbers in the array. boolean canSum(int target, int[] numbers).
  • How Sum, or Which Coin Combination problem: Given a target number and an array of numbers, potentially coins, return either an array containing any combination of the elements from the number array that we can use to add up to exactly the target number. If there is no possible result, return null. int[] canSum(int target, int[] numbers).
  • Best Sum, or the Fewest Number of Coins: Given a target number and an array of numbers, potentially coins, return either an array containing the shortest combination of any of the elements from the number array that we can use to add up to exactly the target number. If there is no possible result, return null. int[] canSum(int target, int[] numbers).
  • Can Concat: Given a target word and an array of strings return a boolean to indicate whether or not the target string can be concatenated by any combination of the strings, or words, in the array. boolean canConcat(string target, string[] words).
  • Count Concat: Given a target word and an array of strings return a number to indicate the total number of ways that the target string can be concatenated by any combination of the strings, or words, in the array. int countConcat(string target, string[] words).
  • All Concat: Given a target word and an array of strings return an array that contains an array for each of the permutations of the ways that the target string can be concatenated by any combination of the strings, or words, in the array. string[][] allConcat(string target, string[] words).

Graph and Tree Traversal Programming Problems