DSA With Kotlin

Dilip PatelDilip Patel
6 min read

Fundamentals

  • Fundamentals of Problem Solving

Basics

  • Positive or Negative number

  • Even or Odd number

  • Sum of First N Natural numbers

  • Sum of N natural numbers

  • Sum of numbers in a given range

  • Greatest of two numbers

  • Greatest of the Three numbers

  • Leap year or not

  • Prime number

  • Prime number within a given range

  • Sum of digits of a number

  • Reverse of a number

  • Palindrome number

  • Armstrong number

  • Armstrong number in a given range

  • Fibonacci Series up to nth term

  • Find the Nth Term of the Fibonacci Series

  • Factorial of a number

  • Power of a number

  • Factor of a number

  • Finding Prime Factors of a number

  • Strong number

  • Perfect number

  • Perfect Square

  • Automorphic number

  • Harshad number

  • Abundant number


Numbers

  • Highest Common Factor (HCF)

  • Lowest Common Multiple (LCM)

  • Greatest Common Divisor

  • Binary to Decimal conversion

  • Octal to Decimal conversion

  • Hexadecimal to Decimal conversion

  • Decimal to Binary conversion

  • Decimal to Octal Conversion

  • Decimal to Hexadecimal Conversion

  • Binary to Octal conversion

  • Octal to Binary conversion

  • Quadrants in which a given coordinate lies

  • Permutations in which n people can occupy r seats in a classroom

  • Maximum number of handshakes

  • Addition of two fractions

  • Replace all 0’s with 1 in a given integer

  • Can a number be expressed as a sum of two prime numbers

  • Count possible decoding of a given digit sequence

  • Calculate the area of a circle

  • Find the prime numbers between 1 to 100

  • Calculate the number of digits in an integer

  • Convert digit/number to words

  • Counting number of days in a given month of a year

  • Finding Number of times x digit occurs in a given input

  • Finding number of integers which has exactly x divisors

  • Finding Roots of a quadratic equation


Recursion

  • Power of a Number

  • Prime Number

  • Largest element in an array

  • Smallest element in an array

  • Reversing a Number

  • HCF of two numbers

  • LCM of two numbers

  • Program to calculate length of the string using recursion

  • Print All Permutations of a String

  • Given an integer N the task is to print the F(N)th term

  • Given a list arr of N integers, print sums of all subsets in it

  • Last non-zero digit in factorial

  • Given a positive integer N, return the Nth row of Pascal’s triangle

  • Given an integer N representing the number of pairs of parentheses, generate all combinations of well-formed (balanced) parentheses

  • Find the Factorial of a number using recursion

  • Find all possible Palindromic partitions of the given String

  • Find all the N bit binary numbers having more than or equal 1’s than 0’s

  • Given a set of positive integers, find all its subsets

  • Given a string s, remove all its adjacent duplicate characters recursively


Strings

  • Check whether a character is a vowel or consonant

  • Check whether a character is an alphabet or not

  • Find the ASCII value of a character

  • Length of the string without using strlen() function

  • Toggle each character in a string

  • Count the number of vowels

  • Remove the vowels from a String

  • Check if the given string is Palindrome or not

  • Print the given string in reverse order

  • Remove all characters from string except alphabets

  • Remove spaces from a string

  • Remove brackets from an algebraic expression

  • Count the sum of numbers in a string

  • Capitalize the first and last character of each word of a string

  • Calculate frequency of characters in a string

  • Find non-repeating characters in a string

  • Check if two strings are Anagram or not

  • Replace a sub-string in a string

  • Replacing a particular word with another word in a string

  • Count common sub-sequence in two strings

  • Check if two strings match where one string contains wildcard characters

  • Print all permutations of a given string in lexicographically sorted order


Arrays

  • Find Largest element in an array

  • Find Smallest Element in an Array

  • Find the Smallest and largest element in an array

  • Find Second Smallest Element in an Array

  • Calculate the sum of elements in an array

  • Reverse an Array

  • Sort first half in ascending order and second half in descending

  • Sort the elements of an array

  • Finding the frequency of elements in an array

  • Sorting elements of an array by frequency

  • Finding the Longest Palindrome in an Array

  • Counting Distinct Elements in an Array

  • Finding Repeating elements in an Array

  • Finding Non Repeating elements in an Array

  • Removing Duplicate elements from an array

  • Finding Minimum scalar product of two vectors

  • Finding Maximum scalar product of two vectors in an array

  • Counting the number of even and odd elements in an array

  • Find all Symmetric pairs in an array

  • Find maximum product sub-array in a given array

  • Finding Arrays are disjoint or not

  • Determine Array is a subset of another array or not

  • Determine can all numbers of an array be made equal

  • Finding Minimum sum of absolute difference of given array

  • Sort an array according to the order defined by another array

  • Replace each element of the array by its rank in the array

  • Finding equilibrium index of an array

  • Rotation of elements of array- left and right

  • Block swap algorithm for array rotation

  • Juggling algorithm for array rotation

  • Finding Circular rotation of an array by K positions

  • Balanced Parenthesis Problem


Advanced Arrays

  • Given an array which consists of only 0, 1 and 2. Sort the array without using any algorithm

  • Find the “Kth” max and min element of an array

  • Move all the negative elements to one side of the array

  • Find the Union and Intersection of the two sorted arrays

  • Find Largest sum contiguous Subarray

  • Minimize the maximum difference between heights

  • Minimum no. of Jumps to reach the end of an array

  • Find duplicate in an array of N+1 Integers

  • Merge 2 sorted arrays without using extra space

  • Kadane’s Algorithm

  • Merge Intervals

  • Count Inversion

  • Best time to buy and Sell stock

  • Find all pairs on integer array whose sum is equal to given number

  • Find if there is any subarray with sum equal to 0

  • Find factorial of a Large Number

  • Find common elements In 3 sorted arrays

  • Rearrange the array in alternating positive and negative items with O(1) extra space

  • Given an array of size n and a number k, find all elements that appear more than “n/k” times

  • Maximum profit by buying and selling a share at most twice

  • Next Permutation

  • Find longest consecutive subsequence

  • Trapping Rain water problem

  • Chocolate Distribution problem

  • Smallest Subarray with sum greater than a given value

  • Three way partitioning of an array around a given value

  • Minimum no. of operations required to make an array palindrome

  • Median of 2 sorted arrays of equal size

  • Median of 2 sorted arrays of different size

0
Subscribe to my newsletter

Read articles from Dilip Patel directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Dilip Patel
Dilip Patel

Software Developer