Practice Programming Problems

Image for post
Image for post

If you are a programmer or a developer it is good to stay sharp on your coding skills. In this article we will explore some practice programming problems using the C -Programming language.

Find The Smallest Positive Integer Value

Problem: Given a sorted array that is in non-decreasing order and made of positive integers, find the smallest positive integer value that cannot be represented as a sum of the elements of any subset of the given set. You are expected to solve this in O(n) time.

Example 1:
Input: arr[] = {1,3,6,10,11,15};
Output: 2

Example 2:
Input: arr[] = {1,1,1,1}
Output: 5

Example 3:
Input: arr[] = {1,1,3,4}
Output: 10

Example 4:
Input: arr[] = {2}
Output: 1

Get the solution code below:

Find the Missing Number

Problem: You are given a list of n-1 integers and these integers are in the range of 1 to n. There are no duplicates in the list. One of the integers is missing in the list. Write an efficient code to find the missing integer. By efficient we mean in O(n) time.

Example:
Input: [1,2,4,6,3,7,8] // Array of size =7 = 8–1, so n=8
Output: 5

Get the code solution below:

Remove Vowels

Problem: Given a word/string remove all of the vowels {a,e,i,o,u,y} from that word.

Example:
Input: Apple
Output: ppl

Get the code solution below:

Anagram

Problem: Write a method to decide if two strings are anagrams of each other. An anagram is a word or phrase that can be formed by rearranging letters of another word or phrase, for example cinema can be formed from iceman.

Example 1:
Input 1: DAD
Input 2: ADD
Output: Yes, they are anagrams

Example 2:
Input 1: MOM
Input 2: TOM
Output: No, they are NOT anagrams

Get the code solution below:

Check If Array is Unique

Problem: Implement an algorithm to determine if a string has all unique characters in O(n).

Example1:
Input: “hello”
Output: No the string is not unique

Example2:
Input: “car”
Output: Yes the string is unique

Get the code below:

Integer Palindrome

Problem: Check if an integer is a palindrome, meaning the number reversed is the same number in O(n) time.

Example 1:
Input: 12321
Output: 12321 is a Palindrome

Example 2:
Input: 12
Output: 12 is NOT a palindrome

Get the code below:

String Palindrome

Problem: Determine if a word or string is a palindrome, meaning the word is the same when reversed.

Example 1:
Input: “MOM”
Output: “MOM” is a palindrome

Example 2:
Input: “TOM”
Output: “TOM” is not a palindrome

Get the code below:

Also a great book to prepare you for coding/programming interviews is called cracking the coding interview. It will help you familiarize yourself with sorting algorithms and problem solving, so be sure to check it out !

Image for post
Cracking The Coding Interview

Thanks for reading this article I hope its helpful to you all ! Keep up the learning, and if you would like more computer science, programming and algorithm analysis videos please visit and subscribe to my YouTube channels (randerson112358 & compsci112358 )

Check Out the following for content / videos on Computer Science, Algorithm Analysis, Programming and Logic:

YouTube Channel:
randerson112358: https://www.youtube.com/channel/UCaV_0qp2NZd319K4_K8Z5SQ

compsci112358:
https://www.youtube.com/channel/UCbmb5IoBtHZTpYZCDBOC1CA

Website:
http://everythingcomputerscience.com/

Video Tutorials on Recurrence Relation:
https://www.udemy.com/recurrence-relation-made-easy/

Video Tutorial on Algorithm Analysis:
https://www.udemy.com/algorithm-analysis/

Twitter:
https://twitter.com/CsEverything

YouTube Channel:

Image for post
Image for post

Computer Science Website:

Image for post
Image for post

Udemy Videos on Algortithm Analysis:

Image for post
Image for post

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store