Logic Based Programs
Introduction to Logic Based Programming:
---------------------------------------
=> This course (LBP) encourages you to use logic and alogrithms to create a
new program.
=> This is an exercise for your brain to train up your logical ability.
=> Logical thinking is not only about solving problems but also beneficial to
your personal and professional life.
=> In this course we can covering almost 300+ programs.
=> Implementation of these programs will be in C, Java and Python.
=> In this material we have given solution for each problem in all these
languages.
Pre-requisite:
--------------
=> Atleast one programming language knowledge is required to solve the
problems.
=> Dedicatation to solve the programs.
Syllabus:
---------
LBP001: Even or Odd Number
LBP002: Weird or Not Weird
LBP003: Leap Year or Not
DURGASOFT, # 202, 2nd Floor, HUDA Maitrivanam, Ameerpet, Hyderabad - 500038,
1 88 85 25 26 27, 72 07 21 24 27/28 | www.durgasoftonline.com
Maii: durgasoftonline@gmail.com
Logic Based Programs
LBP004: E-commerce company Bookshelf
LBP005: Next Number from Integer
LBP006: Free Coffee Cups
LBP007: Extract Digits from the number
LBP008: Sum of Digits
LBP009: Sum of even digits
LBP010: Sum of odd digits
LBP011: Sum of prime Digits
LBP012: Sum of Digits divisible by 3
LBP013: Number of digits
LBP014: Reverse Integer
LBP015: Duck Number
LBP016: Number of Occurrences
LBP017: Paliandrome Number
LBP018: Check Birth Day
LBP019: Decimal to Binary
LBP020: Lucky Customer
LBP021: Christmas offer
LBP022: Niven Number
LBP023: A Special two digit number
LBP024: Sum of even numbers
LBP025: Celsius to Fahrenheit
LBP026: Fahrenheit to Celsius
DURGASOFT, # 202, 2nd Floor, HUDA Maitrivanam, Ameerpet, Hyderabad - 500038,
2 88 85 25 26 27, 72 07 21 24 27/28 | www.durgasoftonline.com
Maii: durgasoftonline@gmail.com
Logic Based Programs
LBP027: Find The Sequence Sum
LBP028: Climbing a stair case
LBP029: Prime Number or Not
LBP030: Valid Palindrome
LBP031: Create PIN using Three given numbers
LBP032: Count special characters
LBP033: Discount for the newyears holiday
LBP034: Email validation
LBP035: Data Encryption Key
LBP036: First Capital Letter
LBP037: Toggle Case of String
LBP038: Find Number of Misses
LBP039: Black Jack Function
LBP040: Secure Data Transmission
LBP041: One Time Password
LBP042: Prime Number Application
LBP043: Newyear Holiday Discount
LBP044: War of Numbers
LBP045: Perfect Number
LBP046: Magic Date
LBP047: Oddish or Evenish
LBP048: Session Length
LBP049: Next Prime
DURGASOFT, # 202, 2nd Floor, HUDA Maitrivanam, Ameerpet, Hyderabad - 500038,
3 88 85 25 26 27, 72 07 21 24 27/28 | www.durgasoftonline.com
Maii: durgasoftonline@gmail.com
Logic Based Programs
LBP050: Sum of digits between two numbers
LBP051: Defanging an IP address
LBP052: Jewels and Stones
LBP053: Shuffled String
LBP054: Get word count
LBP055: String ending matches second String
LBP056: Shuffle the Name
LBP057: Reverse the order of a String
LBP058: Re-form the word
LBP059: Anagrams
LBP060: Max Occurring Character
LBP061: Color of a chess board square
LBP062: Find the Bomb
LBP063: How many vowels
LBP064: X's and O's, Nobody knows
LBP065: Stuttering Function
LBP066: Repeating Letters
LBP067: Double Letters
LBP068: Board Game
LBP069: Remove Every vowel from a String
LBP070: Space between each character
LBP071: VOWEL REPLACER
LBP072: Say "Hello" Say "Bye"
DURGASOFT, # 202, 2nd Floor, HUDA Maitrivanam, Ameerpet, Hyderabad - 500038,
4 88 85 25 26 27, 72 07 21 24 27/28 | www.durgasoftonline.com
Maii: durgasoftonline@gmail.com
Logic Based Programs
LBP073: VALID ZIP CODE
LBP074: Returns the middle character of a string
LBP075: Index of first vowel
LBP076: Longest Word
LBP077: Print all permutations of a string
LBP078: Removing Duplicate Characters from a string
LBP079: Swap corner words and reverse middle characters
LBP080: Valid Hex Code
LBP081: Even Length Words
LBP082: Change Every Letter to the Next Letter
LBP083: First N Vowels
LBP084: Is the String is in Order?
LBP085: Integer to English Words
LBP086: C*ns*r*d Str*ngs
LBP087: Parentheses balance
LBP088: American keyboard
LBP089: Rotate Strings
LBP090: Missing Letters
LBP091: Replace Letters With Position In Alphabet
LBP092: Replace character with it's occurrence
LBP093: First non-repeated character
LBP094: Pangrams
LBP095: Print First Letter of each Word
DURGASOFT, # 202, 2nd Floor, HUDA Maitrivanam, Ameerpet, Hyderabad - 500038,
5 88 85 25 26 27, 72 07 21 24 27/28 | www.durgasoftonline.com
Maii: durgasoftonline@gmail.com
Logic Based Programs
LBP096: Number of vowels
LBP097: Number of consonants
LBP098: Check only digits
LBP099: Capitalize Every word first character
LBP100: Student Rewarded
LBP101: Reading and writing an array
LBP102: Sum of all elements in array
LBP103: Sum of even numbers in an array
LBP104: Sum of odd numbers in an array
LBP105: Sum of prime numbers in an array
LBP106: Sum of palindrome numbers in an array
LBP107: Sum of strong numbers in an array
LBP108: Sum of elements in an array ending with 3
LBP109: Search for an element in an array
LBP110: Sort the elements in an array ASC
LBP111: Sort the elements in an array DESC
LBP112: Binary search
LBP113: Max element in an array
LBP114: Min element in an array
LBP115: Diff between largest and smallest element in array
LBP116: Second largest element in an array
LBP117: Second smallest element in an array
LBP118: Number of occurrences of an element
DURGASOFT, # 202, 2nd Floor, HUDA Maitrivanam, Ameerpet, Hyderabad - 500038,
6 88 85 25 26 27, 72 07 21 24 27/28 | www.durgasoftonline.com
Maii: durgasoftonline@gmail.com
Logic Based Programs
LBP119: Inserting element at first position in an array
LBP120: Inserting element at last position in an array
LBP121: Delete an element from first location in an array
LBP122: Delete an element from last location in an array
LBP123: Delete an element from an array at the given location
LBP124: Delete an element from an array
LBP125: Update an element in an array
LBP126: Update an element in an array
LBP127: Array reverse
LBP128: Increment every element in an array by one unit
LBP129: Number of duplicate elements in array
LBP130: Print unique elements in array
LBP131: Sort an array of 0s, 1s and 2s
LBP132: Replace every element with the greatest element on its right side
LBP133: Sum of two arrays
LBP134: Sum of elements available at even index
LBP135: Sum of elements available at odd index
LBP136: Sum of first and last, second and second last and so on
LBP137: Print reverse of each number in an array
LBP138: Number of even and odd elements
LBP139: Reverse only First half of the elements
LBP140: Difference between two arrays
LBP141: Rearrange an array
DURGASOFT, # 202, 2nd Floor, HUDA Maitrivanam, Ameerpet, Hyderabad - 500038,
7 88 85 25 26 27, 72 07 21 24 27/28 | www.durgasoftonline.com
Maii: durgasoftonline@gmail.com
Logic Based Programs
LBP142: Array of multiples
LBP143: Inclusive Array Ranges
LBP144: Find the Average of the Letters
LBP145: Eliminate Odd Numbers within an Array
LBP146: Positive Count / Negative Sum
LBP147: Return the Sum of the Two Smallest Numbers
LBP148: Retrieve the Last N Elements
LBP149: Mini Peaks
LBP150: All Numbers In Array Are Prime
LBP151: Sum of Adjacent Distances
LBP152: Odd Even Online Game
LBP153: Garments Company Apparel
LBP154: POOLED CAB SERVICE
LBP155: Kth SHORTEST PROCESSING QUEUE
LBP156: INDEX FILTERNING
LBP157: SEVEN BOOM!
LBP158: Positives and Negatives
LBP159: Check if All Values Are True
LBP160: Shared Digits
LBP161: Combined Consecutive Sequence
LBP162: Count 5s And Win
LBP163: Find the Single Number
LBP164: Update Every Element
DURGASOFT, # 202, 2nd Floor, HUDA Maitrivanam, Ameerpet, Hyderabad - 500038,
8 88 85 25 26 27, 72 07 21 24 27/28 | www.durgasoftonline.com
Maii: durgasoftonline@gmail.com
Logic Based Programs
LBP165: Third Largest and Second smallest
LBP166: Sales Report
LBP167: Online Game
LBP168: Array pliandrome
LBP169: Array to Matrix
LBP170: Matrix to Array
LBP171: Word Key
LBP172: Oddly Even
LBP173: Sweet Seventeen
LBP174: BeautifyMe
LBP175: Print Prime Numbers
LBP176: GCD of two numbers
LBP177: Secret information
LBP178: Flight
LBP179: Arrangement
LBP180: Parity bits
LBP181: Second non-repeating character
LBP182: Absolute difference between prime numbers
LBP183: Product with successor
LBP184: Pre-sorted integers in array
LBP185: Savings
LBP186: Half ascending and half descending
LBP187: Last and second-last
DURGASOFT, # 202, 2nd Floor, HUDA Maitrivanam, Ameerpet, Hyderabad - 500038,
9 88 85 25 26 27, 72 07 21 24 27/28 | www.durgasoftonline.com
Maii: durgasoftonline@gmail.com
Logic Based Programs
LBP188: Digital root
LBP189: Absolute difference
LBP190: Lucky draw
LBP191: Test paper set
LBP192: Digits raised to the third power
LBP193: Grocery Shop
LBP194: Password change
LBP195: Session share
LBP196: Modular exponentiation
LBP197: Backspace String Compare
LBP198: Token number
LBP199: Score of the player
LBP200: Perfect Math
LBP201: Reading and Writing Matrix Elements
LBP202: Sum of all matrix elements
LBP203: Sum of all even elements
LBP204: Sum of all odd elements
LBP205: Sum of all prime elements
LBP206: Row wise sum in matrix
LBP207: Column wise sum in matrix
LBP208: Sum of diagonal elements in matrix
LBP209: Sum of opposite diagonal elements in matrix
LBP210: Sum of first and last element in the matrix
DURGASOFT, # 202, 2nd Floor, HUDA Maitrivanam, Ameerpet, Hyderabad - 500038,
10 88 85 25 26 27, 72 07 21 24 27/28 | www.durgasoftonline.com
Maii: durgasoftonline@gmail.com
Logic Based Programs
LBP211: Find the product of diagonal matrix
LBP212: Find the product of opposite diagonal matrix
LBP213: Max element in matrix
LBP214: Min element in matrix
LBP215: Max element in each row of a matrix
LBP216: Min element in each row of a matrix
LBP217: Transpose of the given matrix
LBP218: Trace of the given matrix
LBP219: Find the frequency of odd and even
LBP220: Identity matrix
LBP221: Two matrices are equal or not
LBP222: Addition of two matrices
LBP223: Subtraction of two matrices
LBP224: Multiplication of two matrices
LBP225: Sort all the elements in a matrix in asc order
LBP226: Sort all the elements in a matrix in desc order
LBP227: Sort all the elements in a row in asc order
LBP228: Sort all the elements in a row in desc order
LBP229: Sort all the elements in a column in asc order
LBP230: Sort all the elements in a column in desc order
LBP231: Sparse matrix
LBP232: Swaping of two rows
LBP233: Swaping of two columns
DURGASOFT, # 202, 2nd Floor, HUDA Maitrivanam, Ameerpet, Hyderabad - 500038,
11 88 85 25 26 27, 72 07 21 24 27/28 | www.durgasoftonline.com
Maii: durgasoftonline@gmail.com
Logic Based Programs
LBP234: Interchange the diagonals
LBP235: Upper triangular matrix
LBP236: Lower triangular matrix
LBP237: Scalar matrix multiplication
LBP238: Symmetric matrix
LBP239: Print diagonal elements
LBP240: Square of Each Element of Matrix
LBP241: Sum of even indexed rows in matrix
LBP242: Sum of odd indexed rows in matrix
LBP243: Sum of even indexed cols in matrix
LBP244: Sum of odd indexed cols in matrix
LBP245: Sum of elements whose sum of row index and col index is even
LBP246: Sum of elements whose sum of row index and col index is odd
LBP247: Sum of prime elements
LBP248: Count of prime digits in the given matrix
LBP249: Reverse of each element in matrix
LBP250: Keep paliandrome number and replace remaining with 0's
LBP251: Multiples of 10
LBP252: Employee's Rating Point
LBP253: Encrypted digits
LBP254: Easy Shopping
LBP255: Player's score
LBP256: GlobalAdd
DURGASOFT, # 202, 2nd Floor, HUDA Maitrivanam, Ameerpet, Hyderabad - 500038,
12 88 85 25 26 27, 72 07 21 24 27/28 | www.durgasoftonline.com
Maii: durgasoftonline@gmail.com
Logic Based Programs
LBP257: FunGames
LBP258: The Past Book
LBP259: Morning Prayer
LBP260: Factorial game
LBP261: Speed Maths
LBP262: Puzzle
LBP263: Mathematics class
LBP264: Power function
LBP265: Mathematical tricks
LBP266: Coding standards
LBP267: Party quiz
LBP268: Be Positive
LBP269: Prime Number Busses
LBP270: Sentence making
LBP271: Single Binary Value
LBP272: Item id
LBP273: Next Letter
LBP274: Sum of All Integers
LBP275: Country Visa Center
LBP276: Neon Number
LBP277: Super market pricing
LBP278: Number Container
LBP279: Pronic number
DURGASOFT, # 202, 2nd Floor, HUDA Maitrivanam, Ameerpet, Hyderabad - 500038,
13 88 85 25 26 27, 72 07 21 24 27/28 | www.durgasoftonline.com
Maii: durgasoftonline@gmail.com
Logic Based Programs
LBP280: Validate ATM PIN
LBP281: The Actual Memory Size of Your USB Flash Drive
LBP282: Happy Number
LBP283: Calculate the Mean
LBP284: Factorize a Number
LBP285: Next 5 characters
LBP286: Composite Number
LBP287: Hot and Cold Numbers
LBP288: Not Having Alphabet 'a'
LBP289: MathAtTip
LBP290: TodaysApparel
LBP291: BucketId
LBP292: Decimal to Octal
LBP293: Sum of adjacent elements
LBP294: Vaccination Drive List Preparator
LBP295: Area of the circle
LBP296: Divisible by 5 or 7
LBP297: Ending 3
LBP298: Min and Max
LBP299: Lucky String
LBP300: Last three digits
LBP301: Reverse and Replace
LBP302: Party on cruise
DURGASOFT, # 202, 2nd Floor, HUDA Maitrivanam, Ameerpet, Hyderabad - 500038,
14 88 85 25 26 27, 72 07 21 24 27/28 | www.durgasoftonline.com
Maii: durgasoftonline@gmail.com
Logic Based Programs
LBP303: Airport Security
LBP304: Chocolate factory
LBP305: Digital Logic
LBP306: Security Key
LBP307: Data Encode
LBP308: One Time Password
LBP309: Nearest paliandrome
LBP310: FizzBuzz
Hackerrank URL
--------------
https://www.hackerrank.com/41dec30av2022
How to Watch Sessions?
--------------------
The Sessions are classified into the following categories
1) Basic Programs
2) Formula Based Programs
3) Working with Number related programs
4) Programs on Strings
5) Array Related programs
DURGASOFT, # 202, 2nd Floor, HUDA Maitrivanam, Ameerpet, Hyderabad - 500038,
15 88 85 25 26 27, 72 07 21 24 27/28 | www.durgasoftonline.com
Maii: durgasoftonline@gmail.com
Logic Based Programs
6) Matrix Programs
7) Previously Asked Coding Questions by MNC companies
Session1 : Introduction to Logical Programming
Session2 : Introduction to I/O Statements, Basic Rules for solving
problems
Session3 : LBP1
Session4 : LBP1
Session5 : LBP2
Session6 : LBP3-LBP4
Session7 : LBP5-LBP6
Session8 : LBP6-LBP9
Session9 : LBP10-LBP14
Session10 : LBP15-LBP17
Session11 : LBP18-LBP19
Session12 : LBP20-LBP21
Session13 : LBP21-LBP24
Session14 : LBP25-LBP28
Session15 : LBP29-LBP31
Session16 : LBP31-LBP33
Session17 : LBP34-LBP36
Session18 : LBP37-LBP40
Session19 : LBP41-LBP45
DURGASOFT, # 202, 2nd Floor, HUDA Maitrivanam, Ameerpet, Hyderabad - 500038,
16 88 85 25 26 27, 72 07 21 24 27/28 | www.durgasoftonline.com
Maii: durgasoftonline@gmail.com
Logic Based Programs
Session20 : LBP46-LBP50
Session21 : LBP51-LBP54
Session22 : LBP55-LBP59
Session23 : LBP60-LBP63
Session24 : LBP64-LBP70
Session25 : LBP71-LBP74
Session26 : LBP75-LBP76
Session27 : LBP78-LBP80
Session28 : LBP81-LBP84
Session29 : LBP86-LBP88
Session30 : LBP89-LBP93
Session31 : LBP94-LBP100
Session32 : LBP101-LBP105
Session33 : LBP106-LBP109
Session34 : LBP110-LBP117
Session35 : LBP118-LBP123
Session36 : LBP124-LBP125
Session37 : LBP126-LBP130
Session38 : LBP131-LBP135
Session39 : LBP136-LBP139
Session40 : LBP140-LBP145
Session41 : LBP146-LBP150
Session42 : LBP201-LBP212
DURGASOFT, # 202, 2nd Floor, HUDA Maitrivanam, Ameerpet, Hyderabad - 500038,
17 88 85 25 26 27, 72 07 21 24 27/28 | www.durgasoftonline.com
Maii: durgasoftonline@gmail.com
Logic Based Programs
Session43 : LBP213-LBP223
Session44 : LBP224-LBP228
Session45 : LBP229-LBP234
Session46 : LBP235-LBP240
Session47 : LBP241-LBP250
Session48 : LBP151-LBP155
Session49 : LBP156-LBP160
Session50 : LBP161
Session51 : LBP162-LBP165
Session52 : LBP166-LBP170
Session53 : LBP171-LBP173
Session54 : LBP174-LBP180
Session55 : LBP181-LBP185
Session56 : LBP186-LBP191
Session57 : LBP192-LBP195
Session58 : LBP196-LBP200
Session59 : LBP251-LBP256
Session60 : LBP257-LBP261
Session61 : LBP262-LBP268
Session62 : LBP269-LBP272
Session63 : LBP280-LBP286
Session64 : LBP287-LBP291
Session65 : LBP292-LBP300
DURGASOFT, # 202, 2nd Floor, HUDA Maitrivanam, Ameerpet, Hyderabad - 500038,
18 88 85 25 26 27, 72 07 21 24 27/28 | www.durgasoftonline.com
Maii: durgasoftonline@gmail.com
Logic Based Programs
Session66 : LBP301-LBP305
Session67 : LBP306-LBP310
Session68 : Matrix Programs Revision Part-1
Session69 : Matrix Programs Revision Part-2
Session70 : Matrix Programs Revision Part-3
Session71 : Matrix Programs Revision Part-4
Session72 : LBP273
Session73 : LBP274-LBP279
Session74 : LBP85
Session75 : LBP77
Session76 : LBP77
Session77 : Pattern Programs
DURGASOFT, # 202, 2nd Floor, HUDA Maitrivanam, Ameerpet, Hyderabad - 500038,
19 88 85 25 26 27, 72 07 21 24 27/28 | www.durgasoftonline.com
Maii: durgasoftonline@gmail.com