There are many variations of this problem like find the two repeating numbers, find a missing and a repeating number, etc. The array doesn’t contain any duplicate, one number is missing, find the missing number. Given an array of size n with a range of numbers from 1 to n+1. See k largest(or smallest) elements for more details. Finally, MH has k largest elements and the root of the MH is the kth largest element. For each element, after the kth element (arr to arr), compare it with the root of MH, if the element is greater than the root then make it root and call heapify for MH, Else ignore it. We Build a Min Heap MH of the first k elements. Given a big array, how to efficiently find the kth largest element in it? See Count Inversions in an array for all approaches. How to count all inversions in an unsorted array. Two elements arr and arr in an array arr form an inversion if a > a and i < j. How to count inversions in a sorted array? See find the first unique character for more details. Then traverse the count array and find the smallest index with count as 1. Traverse the given string and store index of the first occurrence of every character, also store count of occurrences. The efficient solution is to use character as an index in a count array. Given a big string of characters, how to efficiently find the first unique character in it? Other variations of this problem like find the minimum element or maximum element in a sorted and rotated array. See Search an element in a sorted and pivoted array for more details. See for more details.Ī sorted array is rotated at some unknown point, how to efficiently search an element in it.Ī simple approach is to use linear search, but we can search in O(Logn) time using Binary Search. For example, if the input array is sorted and if the last or first element is chosen as a pivot, then the worst occurs. The worst case of quickSort occurs when one part after partition contains all elements and other part is empty. In quickSort, we select a pivot element, then partition the given array around the pivot element by placing the pivot element at its correct position in a sorted array. When does the worst case of QuickSort occur? See angle between hour hand and minute hand for more details Find the angle moved by the hour and minute hands, subtract the two angles to find the angle between them. The idea is to take a reference point as 12. How to find angle between hour and minute hands at a given time? Software Engineering Interview Questions.Top 10 System Design Interview Questions and Answers.Top 20 Puzzles Commonly Asked During SDE Interviews.Commonly Asked Data Structure Interview Questions.Top 10 algorithms in Interview Questions.Top 20 Dynamic Programming Interview Questions. Top 20 Hashing Technique based Interview Questions.Top 50 Dynamic Programming (DP) Problems.Top 20 Greedy Algorithms Interview Questions.Top 100 DSA Interview Questions Topic-wise.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |