VARDHAMAN COLLEGE OF ENGINEERING,
HYDERABAD
Autonomous Institute Affiliated to JNTUH
Course Code C2105 Semester: II
COMPETITIVE PROGRAMMING ESSENTIALS
Common to : All Branches
Hours Per Week Hours Per Semester Credits
L T P L T P C
0 0 2 0 0 28 1
OVERVIEW:
This course introduces students to the foundational concepts and techniques used in algorithmic
problem-solving, with a focus on understanding computational power and efficiency. Students will
gain hands-on experience with essential programming constructs and problem-solving strategies
through topics such as bit manipulation, loop structures for generating patterns, recursive
algorithms, and array manipulation. The course also covers techniques for analysing the frequency of
elements in data sets and string manipulation fundamentals. The course aims to develop students'
analytical and problem-solving skills applicable to real-world scenarios.
Course Syllabus:
Understanding Computing Power: Processor speed, Ram Size, 32bit vs 64bit Architecture,
Data Types, Time and Space Complexity, Asymptotic notations, Understanding Constraints.
Programming Basics: Reading Input, writing output, if-else, loops, Pattern Printing, Creating
and Accessing Array Elements, Functions.
Problems:
Easy:
1. Given two integers, n and m. The task is to check the relation between n and
m.https://www.geeksforgeeks.org/problems/java-if-else-decision-making0924/1
2. Prime Check
https://www.geeksforgeeks.org/problems/for-loop-primechecl/1
3. Convert to Binary to decimal
https://www.geeksforgeeks.org/problems/binary-number-to-decimal-number3525/1
4. Print Triangle Pattern
1
12
123
1234
12345
https://www.geeksforgeeks.org/problems/triangle-number/1?
5. Print the pattern for an input n
For n = 3 the pattern will be
333222111
VARDHAMAN COLLEGE OF ENGINEERING,
HYDERABAD
Autonomous Institute Affiliated to JNTUH
332211
321
https://www.geeksforgeeks.org/problems/print-the-pattern-set-1/1
6. For the input n print the following pattern.
Input: 5
Output:
*
**
***
****
*****
****
***
**
*
https://www.geeksforgeeks.org/problems/triangle-pattern-1661718013/1
7. Print the following Pattern
*
***
*****
*******
*********
https://www.geeksforgeeks.org/problems/triangle-pattern-1661492263/1
8. Given an integer n. Return the nth row of the following look-and-say pattern.
1
11
21
1211
111221
https://www.geeksforgeeks.org/problems/decode-the-pattern1138/1
9. Rhombus Pattern
***** | 12345 | ABCDE
***** | 12345 | ABCDE
***** | 12345 | ABCDE
10. Hollow Inverted Full Pyramid Pattern
* * * * * * * * * | 1 2 3 4 5 6 7 8 9 | A B C D E F G
H I
VARDHAMAN COLLEGE OF ENGINEERING,
HYDERABAD
Autonomous Institute Affiliated to JNTUH
* * | 1 7 | A
G
* * | 1 5 | A E
* * | 1 3 | A C
* | 1 | A
11. Diamond Pattern
* | 1 | A
* * * | 1 2 3 | A B C
* * * * * | 1 2 3 4 5 | A B C D E
* * * * * * * | 1 2 3 4 5 6 7 | A B C D E F
G
* * * * * * * * * | 1 2 3 4 5 6 7 8 9 | A B C D E F G
H I
* * * * * * * | 1 2 3 4 5 6 7 | A B C D E F
G
* * * * * | 1 2 3 4 5 | A B C D E
* * * | 1 2 3 | A B C
* | 1 | A
12. Hollow Diamond Pattern
* | 1 | A
* * | 1 3 | A C
* * | 1 4 | A E
* * | 1 5 | A
G
* * | 1 6 | A
I
* * | 1 5 | A
G
* * | 1 4 | A E
* * | 1 3 | A C
* | 1 | A
13. Hollow Hourglass Pattern
VARDHAMAN COLLEGE OF ENGINEERING,
HYDERABAD
Autonomous Institute Affiliated to JNTUH
* * * * * * * * * | 1 2 3 4 5 6 7 8 9 | A B C D E F
G H I
* * | 1 7 | A
G
* * | 1 5 | A
E
* * | 1 3 | A C
* | 1 | A
* * | 1 3 | A C
* * | 1 5 | A
E
* * | 1 7 | A
G
* * * * * * * * * | 1 2 3 4 5 6 7 8 9 | A B C D E F
G H I
Bit Manipulations: Bitwise Operators (&, |, ^, ~, <<, >>), Effect of n&1, n&(n-1), (a ^ a)^b.
Easy:
1. Check ith bit is set or unset.
https://practice.geeksforgeeks.org/problems/check-whether-k-th-bit-is-set-or-not-
1587115620/1
2. Find not repeated number where all other numbers repeated exactly twice.
https://leetcode.com/problems/single-number
3. Find number of set bits in a given number.
https://leetcode.com/problems/counting-bits
https://leetcode.com/problems/number-of-1-bits/
4. Check N is power of 2.
https://practice.geeksforgeeks.org/problems/power-of-2-1587115620/1
5. Minimum bit flips to convert a number
https://leetcode.com/problems/minimum-bit-flips-to-convert-number
6. Check if the binary representation of a number is palindrome or not.
https://practice.geeksforgeeks.org/problems/palindrome-numbers0942/1
Medium:
7. Compute XN
https://leetcode.com/problems/powx-n
8. Find Maximum XOR of two elements in an array.
VARDHAMAN COLLEGE OF ENGINEERING,
HYDERABAD
Autonomous Institute Affiliated to JNTUH
https://practice.geeksforgeeks.org/problems/maximum-xor-of-two-numbers-in-an-
array/1
9. Non repeating two numbers in unsorted array.
https://www.geeksforgeeks.org/problems/finding-the-numbers0215/1
10. Given a string s of length n, find all the possible non-empty sub sequences of the
string s in lexicographically-sorted order.
https://www.geeksforgeeks.org/problems/power-set4302/1
Recursion : Identifying Base case and General Case, Types of Recursions.
Easy:
1. Factorial of a number
https://www.hackerrank.com/contests/c-programming-test/challenges/finding-
factorial-of-n-number/problem
2. Fibonacci Sequence
https://www.hackerrank.com/challenges/ctci-fibonacci-numbers/problem
3. GCD of two numbers
https://leetcode.com/problems/find-greatest-common-divisor-of-array/
Medium:
1. Towers of Hanoi
https://www.geeksforgeeks.org/problems/tower-of-hanoi-1587115621/1
2. Power Function iterative/Recursive/Bit Manipulation
https://www.geeksforgeeks.org/problems/power-of-numbers-1587115620/1
3. Count Good Numbers
https://leetcode.com/problems/count-good-numbers/
Hard:
4. Permutation sequence
https://leetcode.com/problems/permutation-sequence
5. Number of digit one
https://leetcode.com/problems/number-of-digit-one
Arrays: Definition, creating 1D array, accessing array elements, Permutations and
combinations.
Easy:
1. Reverse Entire Array + Reverse Part of Array
https://www.geeksforgeeks.org/problems/reverse-sub-array5620/1
2. Leaders in Array
https://www.geeksforgeeks.org/problems/leaders-in-an-array-1587115620/1
3. No of Even/Odd numbers in given range
VARDHAMAN COLLEGE OF ENGINEERING,
HYDERABAD
Autonomous Institute Affiliated to JNTUH
https://leetcode.com/problems/count-odd-numbers-in-an-interval-range
4. Product array puzzle
https://www.geeksforgeeks.org/problems/product-array-puzzle4525/1
Medium:
1. Rotate Array by K times
https://leetcode.com/problems/rotate-array/
2. Sum of even numbers in an array
https://leetcode.com/problems/sum-of-even-numbers-after-queries/
3. Maximum sub array sum
https://leetcode.com/problems/maximum-subarray/
4. Sum of all sub arrays
https://www.geeksforgeeks.org/problems/sum-of-subarrays2229/1
5. Min Swaps to bring all Elements <= K
https://www.geeksforgeeks.org/problems/minimum-swaps-required-to-bring-all-
elements-less-than-or-equal-to-k-together4847/1
Hard:
1. Majority Element
https://www.geeksforgeeks.org/problems/majority-element-1587115620/1
2. Maximum value of |arr[i] – arr[j]| + |i – j|
https://www.geeksforgeeks.org/problems/maximum-value-of-difference-of-a-pair-of-
elements-and-their-index/1
Frequency logic :
Easy:
1. Print the frequency count of array elements.
https://practice.geeksforgeeks.org/problems/frequency-of-array-elements-
1587115620/1
2. Print the not-repeated elements of array elements.
https://leetcode.com/problems/remove-duplicates-from-sorted-array/
3. Find the missing number in an unsorted array.
https://leetcode.com/problems/missing-number/
4. Given a string, find the first repeated character in it.
https://practice.geeksforgeeks.org/problems/find-first-repeated-character4108/1
Medium:
1. Smallest Positive Missing Integer
https://www.geeksforgeeks.org/problems/smallest-positive-missing-number-
1587115621/1
2. Bulls and Cows
VARDHAMAN COLLEGE OF ENGINEERING,
HYDERABAD
Autonomous Institute Affiliated to JNTUH
https://leetcode.com/problems/bulls-and-cows/
3. Super ascii string checker.
https://www.hackerearth.com/problem/algorithm/super-string/
Strings: Creating Strings, Ascii representation of characters.
Easy:
1. Number of occurrences of each character in string.
https://www.hackerrank.com/contests/codefusion-18-2/challenges/string-and-
occurrences
2. Invert the case of each character in a string.
https://www.hackerrank.com/contests/codegolfdone/challenges/golf2
3. Check the given String is Palindrome or not.
https://practice.geeksforgeeks.org/problems/palindrome-string0817/1
4. Check the given two strings are anagrams or not.
https://leetcode.com/problems/valid-anagram/
5. longest-distinct-characters-in-string
https://www.geeksforgeeks.org/problems/longest-distinct-characters-in-
string5848/1
Medium:
1. Find largest palindromic sub string. Example: AN = "maqxbbcvcbbxyzab";
AN: | m | a | q | x | b | b | c | v | c | b | b | x | y | z | a |b |
AN[3:11] = "xbbcvcbbx" is a substring that is also a palindrome
https://practice.geeksforgeeks.org/problems/longest-palindrome-in-a-string3411/1
2. Reverse Words of a sentence
https://leetcode.com/problems/reverse-words-in-a-string
3. Count occurrences of Anagrams
https://www.geeksforgeeks.org/problems/count-occurences-of-anagrams5839/1
Hard:
1. Enclosing substring.
https://leetcode.com/problems/minimum-window-substring/
2. Zig Zag Conversion
https://leetcode.com/problems/zigzag-conversion/
Additional Problems:
1. Difference summation with array index matching.
2. Minimum chairs for group timings.
3. Replace in string with zero or one.
VARDHAMAN COLLEGE OF ENGINEERING,
HYDERABAD
Autonomous Institute Affiliated to JNTUH
4. Maximize sum by shifting from one array to other at most once.
5. Saga of Missing Coin
6. Construct a number with x set bits followed by y unset bits.
7. Check a, b are of same sign.