DSA1 HARD




DSA1 HARD 



Maximum count of distinct sized subarrays with given sum Manish Shaw
Find a number in sorted and Rotated Array using binary searchAnkit Srivastava
Count occurence of a number in a sorted array using binary search Dev Mittal
Count number of elements which are smaller than given number using binary searchDev Mittal
Given an array that is sorted, but after sorting some elements are moved to either of the adjacent positions, i.e., arr[i] may be present at arr[i+1] or arr[i-1], search the given element in this array
Find smallest number in sorted array using binary search
Nikhil Devrasetty
Find the majority element in array.
1. Given an array, find the total number of inversions of it. If (i < j) and (A[i] > A[j]), then pair (i, j) is called an inversion of an array A. We need to count all such pairs in the array. and time complexity should be < n2
Print a 2D matrix in spiral form
. Given an array that is sorted, but after sorting some elements are moved to either of the adjacent positions, i.e., arr[i] may be present at arr[i+1] or arr[i-1], search the given element in this array and time complexity should be <n
print 2D array in spiral form
Given 2 arrays Print common elements between them TC should be O(N)
Find The Median Of Two Sorted Array Saurav tiwari
Sort Array 0's 1's&2's
What is algorithmsdarshak sorathiya
What is data structures darshak sorathiya
What is arraydarshak sorathiya
Diff b/w array and linkedlistdarshak sorathiya
what is hashingdarshak sorathiya
darshak sorathiya
https://leetcode.com/problems/first-missing-positive/darshak sorathiya
darshak sorathiya
triplet sum and maximum product of sub arraynihal shaik
Find the maximum element in a sorted rotated array
- Calculate the sum of border of the matrix.
- Time complexity
1. Number of element smaller than a given number in a sorted array. (binary search)himanshu manu
2. Merge two sorted arrays. (variation)himanshu manu
pair sum implementation from brute force to reduced complexityAditi namdeo
Linear & Binary searchpavan bhansali
Program to find product of the digits
Array and manipulations
Insertion sort & its working
time complexity of basic sorting techniques
Does JAVA has Pointers.
Bubble and Selection Sort
Coding on Arrays
Hashing - Hashmaps & hashsets & their implementation
1)WAP to reverse a Word without using extra space
2)Given array of number show unique number & show each number only 1 time.(write 2 Methods) using Hashing
3) multiplication of every digit in given number ex input= 32 output = 6 (3*2)
two Given Sorted arrays arr1 ={10,15,20,5,30} and arr 2 ={30,5,30,80}, count the number of common elements present in the arrayPranjul Gupta
Given two sorted arrays and a number x, find the pair whose sum is closest to x and the pair has an element from each array. (geeks for geeks)
We are given two arrays ar1[0…m-1] and ar2[0..n-1] and a number x, we need to find the pair ar1[i] + ar2[j] such that absolute value of (ar1[i] + ar2[j] – x) is minimum.
Pranjul Gupta
an binary array {0,0,0,1,1,1}, find the count of 1's present in the arraygive. (use log(n) time ie, binary search) (geeks for geeks)Pranjul Gupta
merge two sorted array without duplicatesPranjul Gupta
1 - Implement merge sort,
2 - Given an array of integers, print the most frequent element in the given arrays
3 - Given a sorted array and a number k, find the frequency of k in the given array.
4 - Median of an array
5 - Find equilibrium point in an array
6 - Maximum count of distinct sized subarray with given sum.
7 - Sort only the position numbers from an array
8 - Next greater element
9 - Previous greater element
10 - find subarray which is equal to sum
11 - find pairs of sum
12 - find subarray which is equal to 0 and 1
13 - Union of two array
14 - Intersection of two array
15 - Count distinct elements
16 - Median of two array
17 - Container with most water
18 - Given an unsorted array of both negative and positive integer. The task is place all negative element at the end of array without changing the order of positive element and negative element.
19 - Given an array of integer and a number sum. Find the number of pairs of integer in the array whose sum is equal to sum.
20 - Print ABbCccDddd
21 - Quick sort
22 - Missing element and repeating element
23 - You are given an unsorted array with both positive and negative elements. You have to find the smallest positive number from the array.
24 - Given a sorted array of distinct integers and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.
25 - Given an m X n integer matrix, if an element is 0, set it's entire row and column to 0's.
26 - Given an array of size N containing only 0s, 1s and 2s. Sort the array in ascending order.
1. Common elements
Mechate Lavanyasai Kumar
2. Zero-Sum Subarrays
Mechate Lavanyasai Kumar
1. Given a sorted array of distinct integers and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.Rajat Singhal
1. Given a sorted array of distinct integers and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.Rajat Singhal
Hashing, Searching: Search all triplets having a sum of zero in a given array using hashing.
Input: {-3, 1, 4, -5, -4, 2, 3}
Output: {-3, 1, 2} {1, 4, -5} {2, 3, -5} {1, 3, -4}


Array, Sorting: Given two sorted arrays, X[] and Y[] of size m and n each, merge elements of X[] with elements of array Y[] by maintaining the sorted order, i.e., fill X[] with the first m smallest elements and fill Y[] with remaining elements.
Input:
X[] = { 1, 4, 7, 8, 10 }
Y[] = { 2, 3, 9 }

Output:
X[] = { 1, 2, 3, 4, 7 }
Y[] = { 8, 9, 10 }
Nikhil Arvindbhai Butani
1. Two Sum ProblemTarun Pandey
2. Spiral Print Problem in 2-D MatrixTarun Pandey
1. Find all the peak elements within an array.Pradeep Reddy
2. Find missing and repeated element in a given arrayPradeep Reddy
Given an array of strings strs, group the anagrams together. You can return the answer in any order.
An Anagram is a word or phrase formed by rearranging the letters of a different word or phrase, typically using all the original letters exactly once.
soumya ghose
Example 1:
Input: strs = ["eat","tea","tan","ate","nat","bat"]
Output: [["bat"],["nat","tan"],["ate","eat","tea"]]
Nikhil Arvindbhai Butani
What are algorithmDarshak Sorathiya
What are data structureDarshak Sorathiya
What is arrayDarshak Sorathiya
diff bw array and linkedlistDarshak Sorathiya
Diff bw linear search and binary searchDarshak Sorathiya
Time complexity for linear search and binary searchDarshak Sorathiya
https://leetcode.com/problems/word-break-ii/Darshak Sorathiya
yDarshak Sorathiya
Find First and Last Position of Element in Sorted Array (https://leetcode.com/problems/find-first-and-last-position-of-element-in-sorted-array/)Rajat Singhal
1. Introduce YourselfThomson Naidu
2.
The DNA sequence is composed of a series of nucleotides abbreviated as 'A', 'C', 'G', and 'T'.

For example, "ACGAATTCCG" is a DNA sequence.
When studying DNA, it is useful to identify repeated sequences within the DNA.

Given a string s that represents a DNA sequence, return all the 10-letter-long sequences (substrings) that occur more than once in a DNA molecule. You may return the answer in any order.

Input: s = "AAAAACCCCCAAAAACCCCCCAAAAAGGGTTT"
Output: ["AAAAACCCCC","CCCCCAAAAA"] (https://leetcode.com/problems/repeated-dna-sequences/)
Thomson Naidu
3. Given a sorted array arr[] of integers and an integer k, the task is to find the smallest elements in the array which is greater than k. Note that k may or may not be present in the array. if No number is greater than k then print -1

Input: arr[] = {2, 3, 5, 6, 6, 9,10}, k = 6
Output: 9
Input: arr[] = {1, 1, 2, 5, 5, 7}, k = 8
Output: -1

Input: arr[] = {-2, 1, 2, 5, 5, 7}, k = -3
Ouptut:-2
Thomson Naidu
https://leetcode.com/problems/find-first-and-last-position-of-element-in-sorted-array/Ashim Kaushal
https://leetcode.com/problems/subarray-sum-equals-k/Ashim Kaushal
1. Find the most frequent element in the given array.Ashim Kaushal
2. https://leetcode.com/problems/search-in-rotated-sorted-array/Ashim Kaushal
1) find subarray with given sumAkshit Jain
1. Elaborate array in detailsDilip Rathod
2. Write a program to read and display array elements - implemented
3. Write a program to remove duplicate elements from an array - implemented
4. What are searching algorithms and which is more efficient and why?
5. Write a program to demonstrate binary search - implemented
6. What are various sorting algorithms and their time complexity?
7. Implement merge sort - implemented
8. Use of hashing
9. Hash Table
10. Hash Function
Dilip rathod
https://leetcode.com/problems/next-permutation/Inderjot Singh
https://leetcode.com/problems/valid-sudoku/Inderjot Singh
https://leetcode.com/problems/sudoku-solver/Inderjot Singh
https://leetcode.com/problems/median-of-two-sorted-arrays/Inderjot Singh
https://leetcode.com/problems/n-queens/
https://leetcode.com/problems/happy-number/kaur
There are n workers. You are given two integer arrays quality and wage where quality[i] is the quality of the ith worker and wage[i] is the minimum wage expectation for the ith worker.ashish sarkar
We want to hire exactly k workers to form a paid group. To hire a group of k workers, we must pay them according to the following rules:
Every worker in the paid group should be paid in the ratio of their quality compared to other workers in the paid group.
Every worker in the paid group must be paid at least their minimum wage expectation.
Given the integer k, return the least amount of money needed to form a paid group satisfying the above conditions. Answers within 10^-5 of the actual answer will be accepted.
Input: quality = [10,20,5], wage = [70,50,30], k = 2
Output: 105.00000
Explanation: We pay 70 to 0th worker and 35 to 2nd worker.
Input: quality = [3,1,10,10,1], wage = [4,8,2,2,7], k = 3
Output: 30.66667
Explanation: We pay 4 to 0th worker, 13.33333 to 2nd and 3rd workers separately.
Q !Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it can trap after raining.hari om choudhary
Example 1:
Input: height = [0,1,0,2,1,0,1,3,2,1,2,1]
Output: 6
Explanation: The above elevation map (black section) is represented by array [0,1,0,2,1,0,1,3,2,1,2,1]. In this case, 6 units of rain water (blue section) are being trapped.
Q 2
Given a sorted array and a number x, find a pair in an array whose sum is closest to x.
Examples:
Input: arr[] = {10, 22, 28, 29, 30, 40}, x = 54
Output: 22 and 30
Input: arr[] = {1, 3, 4, 7, 10}, x = 15
Output: 4 and 10
Find the Factorial of Given Number - solvedManjunath
Implement Binary Search - solvedManjunath
Find whether an array is subset of another array using hashing set - solvedManjunath
Find the missing numbers
Satya Pravallika Bhuvanagiri
Binary search
Satya Pravallika Bhuvanagiri
Add two strings which are integers
Satya Pravallika Bhuvanagiri
1. Triplet with given sum.
2. Third largest element in the array.
Dalchand Kumawat
Given an array of positive integers. Find the length of the longest sub-sequence such that elements in the subsequence are consecutive integers, the consecutive numbers can be in any order.
[1,8,9,7,2,5,3,6]
length: 5
{8,9,7,5,6}
Expected Time Complexity: O(N).
Expected Auxiliary Space: O(N). --
Shashidhar
3)Write a program to count the total number of subarrays with equal 0's and 1's -- not solved ; i/p: [1,0,1,0] o/p: 4 ; Expected Time Complexity: O(n); Expected Auxiliary Space: O(n).Shashidhar
Write a program to find the transition element index in the sorted binary array in O(logn) timeShashidhar
1)Can you explain what is hashing -- partially Answered
2)Lets say you have huge amount of data like millions which type of sorting technique is good -- Answered
3)Max Circular Subarray Sum
Given an array arr[] of N integers arranged in a circular fashion. Your task is to find the maximum contiguous subarray sum.

Input:
N = 7
arr[] = {8,-8,9,-9,10,-11,12}

Output: 22

Explanation:
Starting from the last element of the array, i.e, 12, and
moving in a circular fashion, we have max subarray as 12, 8, -8, 9,-9, 10, which gives maximum sum as 22.

Expected Time Complexity: O(N).
Expected Auxiliary Space: O(1).


3)Lets say you have an array of binary integers [1,0,1,0,1
Write a program to count the total number of subarrays with equal 0's and 1's

Sub arrays: 10,01,10,01,1010,0101
o/P:6

Expected time complexity :O(N) time
Expected Space complexity: O(N) space
Shashidhar
https://leetcode.com/problems/sudoku-solver/Hiren Patel
https://leetcode.com/problems/group-anagrams/Hiren Patel
Find the most frequent character in the string.Abhay Bhardwaj
i) what is data structure??Hiren Patel
ii)What's algorithm?
1)what is an array?Hiren Patel
2)what are searching and sorting algorithms?Hiren Patel
3)What is hashing in data structure?
4)what is time complexity of any program?Hiren Patel
5)what's the space complexity of any program?
https://leetcode.com/problems/sudoku-solver/Hiren Patel
https://leetcode.com/problems/group-anagrams/Hiren Patel
https://leetcode.com/problems/search-in-rotated-sorted-array/
https://leetcode.com/problems/3sum/
1. Given an array arr, and an element X, find the minimum number of elements required to be added to the current array arr so that the median of all the elements of the array A arr should be X.Lakkakula Venkatesh
2. Merge Sort implement.Lakkakula Venkatesh
>what is data structure??Sanket Sorathiya
Define Time complexity
https://leetcode.com/problems/longest-common-subpath/
https://leetcode.com/problems/find-k-th-smallest-pair-distance/
Aman Kumar
pavan bhansali
>what is sorting algorithm?
https://leetcode.com/problems/sort-colors/Aman Kumar
Write a Program to find a missing element in an array.
Write a Program to find two missing elements in an array.
Which of the following sort will be useful for a given set of input? Selection sort or Insertion sort ?
Write a Program to print the distinct elements and unique elements in an array.
pavan bhansali
Increasing Triplet Subsequence:
Given an integer array nums, return true if there exists a triple of indices (i, j, k) such that i < j < k and nums[i] < nums[j] < nums[k]. If no such indices exist, return false.
Example 1:
Input: nums = [1,2,3,4,5]
Output: true
Explanation: Any triplet where i < j < k is valid.Rahul Kumar Yadav
Example 2:
Input: nums = [5,4,3,2,1]
Output: false
Explanation: No triplet exists.
Example 3:
Input: nums = [2,1,5,0,4,6]
Output: true
Explanation: The triplet (3, 4, 5) is valid because nums[3] == 0 < nums[4] == 4 < nums[5] == 6.
1)Given an array arr[] of size N. The task is to maximize the minimum value of the array after performing given operations. In an operation, value x can be chosen and

A value 3 * x can be subtracted from the arr[i] element.
A value x is added to arr[i-1]. and
A value of 2 * x can be added to arr[i-2].

2) Given an array of items, an i-th index element denotes the item id’s, and given a number m, the task is to remove m elements such that there should be minimum distinct id’s left. Print the number of distinct id’s.
Anu Kumari Gupta
1. https://leetcode.com/problems/trapping-rain-water/
2. https://leetcode.com/problems/search-a-2d-matrix/suraj mall
4. https://leetcode.com/problems/maximum-subarray/
3. time and space complexity
Tarun Pandey
Find the missing numbers
Satya Pravallika Bhuvanagiri
Happy numberkaur
1. What is the time complexity?
int i, j, k = 0;
for (i = n / 2; i <= n; i++) {
for (j = 2; j <= n; j = j * 2) {
k = k + n / 2;
}
}
Jomish John
2. What is the output?
int main()
{
int arr[] = { 1, 2, 3, 4, 5, 6, 7 };
int n = sizeof(arr) / sizeof(arr[0]);
func1(arr, 2, n);
printArray(arr, n); //Prints arr & n
return 0;
}

void func2 (int arr[], int n)
{
int temp = arr[0], i;
for (i = 0; i < n - 1; i++)
arr[i] = arr[i + 1];
arr[n-1] = temp;
}

void func1(int arr[], int d, int n)
{
for (int i = 0; i < d; i++)
func2(arr, n);
}
Jomish John
3. WAP to find duplicates from an unsorted array.
Jomish John
4. What is the output?

public static void main(String []args)
{
int NUM = 0,I=0,J=0;
int arr[] = {7,8,9,11,17} ;

for (I = 0; I < arr.length; I++)
{
NUM = 0;
for (J = 2; J < (arr[I] / 2); J++)
{
if (arr[I] % J == 0)
{
NUM = 1;
break;
}
}

if (NUM == 0)
System.out.println(arr[I]);
}
}

//7 11 17
Jomish John
sudhanshu shekhar
https://leetcode.com/problems/next-permutation/Vipul lohani
Binary searchkaur
Plus one
Write a Program to find a missing element in an array.pavan bhansali
What is hashing ? What are Hashmaps ? Hashsets ?
Which of the following sort will be useful for a given set of input? Selection sort or Insertion sort ?
Write a Program to print the distinct elements and unique elements in an array.
1. What is the output of following program?Nikhil Singh
Nikhil Singh
void print(int n, int j)Nikhil Singh
{Nikhil Singh
if (j >= n)
return;
if (n-j > 0 && n-j >= j)
System.out.println( j, n-j);
print(n, j+1);
}Nikhil Singh
int main()
{
int n = 8;
print(n, 1);
}
Nikhil Singh
2.Given an unsorted array arr[] of both negative and positive integer. The task is place all negative element at the end of array without changing the order of positive element and negative element.
Time - O(N) Space -O(1)Nikhil Singh
Examples:
Input : arr[] = {1, -1, 3, 2, -7, -5, 11, 6 }
Nikhil Singh
Output : 1 3 2 11 6 -1 -7 -5
Advantages and Disadvantages of Array
[Partially Answered]Himanshu Manu udvani
- What is difference between Linear & Non Linear data structure? Give few examples?
- Is Array is a linear data structure?
[Not Answered]
-Difference between Hashmap and hashset
[Partially Answered]
- Print the given matrix in spiral form
Input: 1 2 3 4
5 6 7 8
9 10 11 12
13 14 15 16
Output: 1 2 3 4 8 12 16 15 14 13 9 5 6 7 11 10
[Not Coded]
- Sort an array using merge sort algorithm
[Not Coded]
- What are different sorting algorithm. Comparison of them
[Answered]
https://leetcode.com/problems/combination-sum/Aman Kumar
Search in rotated sorted array, plus onekaur
https://practice.geeksforgeeks.org/problems/smallest-distant-window3132/1Tarun pandey
https://leetcode.com/problems/sum-of-even-numbers-after-queries/
What is hashing? Advantages ?Shivam Singh
What is an array its types ?Shivam Singh
Explain searching and sorting and their types?Shivam Singh
Implement logic to check string is pelindrome or not.Shivam Singh
Find the second largest element from given array of elementsShivam Singh
https://leetcode.com/problems/find-k-th-smallest-pair-distance/
https://leetcode.com/problems/check-if-array-pairs-are-divisible-by-k/
Danish khan
https://leetcode.com/problems/find-first-and-last-position-of-element-in-sorted-array/
https://leetcode.com/problems/rotate-array/
https://leetcode.com/problems/spiral-matrix-ii/
https://leetcode.com/problems/sliding-window-maximum/
Trapping Rain Water - https://leetcode.com/problems/trapping-rain-water/ANAND SHUKLA
Find all missing numbers in an array
pavan bhansali
N = 7
2 , 3, 4, 5, 7
minimun number is 1

No comments:

Post a Comment

ads vert

Basic HTML Tables - Layout, HTML Tables, Attributes, Aside, Footer, Tr tag, Td tag, Th tag, Tbody

  Basic HTML Tables - Layout, HTML Tables, Attributes, Aside, Footer, Tr tag, Td tag, Th tag, Tbody < table >      < thead >    ...