A repository to contribute solutions to some algorithmic questions.
- Fork the repository.
- Clone your forked repository.
- Open the cloned repository in an IDE.
- Create a folder with your name.
- Solve and add any four questions from below in that folder.
- Make the pull request.
Note: You can use any programming language for the submission.
- Write a program to input a string and check if it is a palindrome or not.
Input: hannah
Output: String is palindrome
- Write a program to input an array of integers and output the maximum element of the array.
Input: 1 2 3 4 5
Output: 5
- Write a program to print the following pattern:
Output:
*
**
***
****
*****
- Write a program to print the following pattern:
Output:
*
**
***
****
*****
- Find the Kth Maximum number in a given array in linear time complexity.
Input: arr = [1, 2, 4, 3, 5], k = 2
Output: 4
Input: arr = [1, 2, 2, 4, 4, 6, 5, 5], k = 3
Output: 5
- Move all negative numbers to beginning and positive to end with constant extra space and linear time complexity.
Input: -12, 11, -13, -5, 6, -7, 5, -3, -6
Output: -12 -13 -5 -7 -3 -6 11 6 5
- Given an array of integers
nums
and an integertarget
, return indices of the two numbers such that they add up totarget
.
Input: nums = [2,7,11,15], target = 9
Output: [0,1]
Output: Because nums[0] + nums[1] == 9, we return [0, 1].
- Remove duplicates from a sorted array of positive numbers and return the remaining array, with the unique elements put towards the starting of the array, it doesn't matter what you put after the unique elements in the array.
Input: nums = [1,1,1,2,3,4]
Output: nums = [1,2,3,4,-1,-1]