Leetcode Hard Problem, Simplest Solution Given two sorted arrays nums1 and nums2 of size m and n respectively, return the median of the two sorted arrays. The overall run time complexity should Read more →
Sorting
47 postsGiven dictionary, sort its items using key-value difference. Input : test_dict = {3 : 9, 1 : 4, 9 : 13, 1 : 10, 8 : 9 } Output : {8: 9, Read more →
1. Overview We’ll discuss Quadsort in this article. It’s a new stable sorting algorithm. We’ll begin from the concept of stable sorting and some sorting algorithms. Then, we’ll discuss the Quadsort algorithm Read more →
Given a matrix mat[][] of size M x N integers where M is the number of rows and N is the number of columns and a number K. The task is to Read more →
Radix Sort is the answer when elements are in the range from 1 to n^2. The idea of Radix Sort is to do digit by digit sort starting from least significant digit Read more →
Sort a list in JAVA and then return the index of elements in sorted order. Examples: Input : [2, 3, 1, 4, 5] Output : [2, 0, 1, 3, 4] After sorting Read more →
Given a number num (0 < num < 108), the task is to sort the digits of the number such that even indices are in ascending order and odd indices in descending Read more →
Given an array A of size N. A boolean array B consisting of N-1 elements indicates that if B[i] is 1 then A[i] can be swapped with A[i+1]. Find if A can Read more →
Given a string s, the task is to print all permutations of a string that are in ascending order, i.e., their characters are in ascending order. Examples: Input: Cplusplus Output: Cllppssuu Out Read more →
Given an array arr[] of 2N integers, where N is any positive integer. The task is to divide the array into N pairs such that the pair sum minimizes the maximum sum Read more →