Skip to content
W3colleges

W3colleges

  • Home
  • Algorithms
    • Analysis of Algorithms
    • Searching
    • Sorting
    • Divide and Conquer
    • Greedy
    • Dynamic Programming
    • Backtracking
    • Branch and Bound
    • Graph And Algorithms
    • Pattern Searching
    • Mathematical
    • Geometric
  • Data Structures
    • Array
    • Queue
    • Stack
    • Linked List
    • Binary Tree
    • Graph
    • Hashing
    • String
  • C Programming
    • Basic
    • Pointers
    • Operators
    • Control Statement
    • Loops
    • Function
    • Array
    • Sorting
    • Advanced
  • C++ Programming
    • C++ Basics
    • Operators
    • Control Statements
    • Functions
    • Array
    • Constuctor and Destructor
    • Overloading & overriding
    • C++ Library
    • STL
    • Misc
      • Object Oriented
      • Inhertiance
      • Sorting
      • Advanced
  • Programs
    • C Programs
    • C++ Programs
  • CS Core
    • Operating Systems
    • DBMS
    • Computer Networks
  • Interviews
  • Contests
  • Python

Rearrange List to Follow Given Operators Sequence

Given a list of n integers and consider another list which has n-1 “<” or “>” operators. Your task is to form a valid sequence by rearranging the initial list such that it follows the operator’s sequence in the final list. “vector” is a list containing integers “operators” is a list containing operators constraints: 2<=n<=1000. Examples: Input :… Read More »

Arrays Python Programs
Two-pointer Vector

Vertical order traversal of Binary Tree using Map

We all must have encountered the vertical Traversal of the Binary Tree problem. In this version of the problem we will see how we can perform the traversal vertically while keeping in mind that the order should be from left to right(just like increasing x coordinates): If the x coordinates are same then the node appearing on the… Read More »

Greedy Java Programs Tree
Binary Tree Tree Traversal

Maximize Array sum by swapping K elements with another array

Find maximum sum of array A, where k swap can be possible between array A and B. Size of array A and B is N. Examples: Input : N = 5 k = 5 A[5] = 5 6 5 6 6 B[5] = 1 2 5 4 4 Output : 28 Explanation: Sort array A in increasing order… Read More »

Arrays Mathematical Python Programs

Sort the elements in ascending order of sum of its occurrence

Given an unsorted array of integers which may contain repeated elements, sort the elements in ascending order of sum of its occurrence and print only distinct elements. If there exist more than one element whose sum of occurrences are same then, the one which is smaller, will come first. Examples: Input : arr[] = [8, 2, 4, 2,… Read More »

Arrays Python Programs Sorting

Find Minimum Cost to Match Arrays A and B as Permutations

Given two array A[] and B[] of length N, the task is the find the minimum cost to make array A[] a permutation of array B[], where the cost of incrementing or decrementing an element by 1 is 1. Note: You are allowed to increase or decrease only 1 element of A at a time. Examples: Input :… Read More »

Arrays C++ Programs Dynamic Programming
Permutation

Find Minimum Rotations to Sort an Array in Non-Decreasing Order

Given an array of n integers, you need to find minimum number of below operation such that arrays becomes sorted in non-decreasing order. In a single operation you can rotate the given array clockwise one time. Print -1 if it is not possible to sort the array. Examples: Input: {8, 4, 6} Output: 2 Explanation: After applying operation… Read More »

Arrays C++ Programs Java Programs Sorting
Sorting

Winner in Array Transformation Game with Permutation Goal

Given an array of integers, A[] of size n with elements in range 1 to n may not consist of all the numbers from 1 to n. There are two players  P1 and P2, who play in alternate turns in each turn a player can choose any index i and increase only A[i] by 1 only once in… Read More »

Arrays C Programs C++ Programs Sorting
Permutation Sorting

Sort a string without altering the position of vowels

Given a string S of size N, the task is to sort the string without changing the place of vowels. Examples: Input: S = “example” Output: elampxe Explanation: The consonants are xmpl. After sorting it becomes lmpx. Now update the string after replacing each consonants with sorted consonants. Input: S = “Cplusplus” Output: Clluppsus Recommended: Selection Sort Approach:… Read More »

C++ Programs Sorting Strings
Sorting Strings

Count number of pair such that (Max/min) is less than 2 in Array

Given an array arr[] of size N (0 < arr[i] < 106), the task is to find the total count of pairs such that by dividing the largest number by the smallest number of the pair, the result is < 2. Examples: Input: arr[ ] = { 3, 12, 5, 13 } Output: 2 Explanation:  The two such… Read More »

Arrays C++ Programs Mathematical Sorting
Sorting

Check if binary string can be sorted

Given a binary string consisting of ‘0’ & ‘1’. You can remove any subsequence in given string but can’t pick adjacent indices. Print “POSSIBLE” if string can be sorted else print “NOTPOSSIBLE”. Examples: Input: 110 Output: POSSIBLE Explanation: If we remove characters at index 1 & 3 we are left with “1” which is sorted. Input: 101001111 Output:… Read More »

C++ Programs Sorting Strings
Binary String Sorting Strings

Posts navigation

  • ← Previous
  • 1
  • …
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • …
  • 40
  • Next →

Recent Posts

  • Four Pillars of Object-Oriented Programming (OOPS)
  • Minimize Difference Between Sum of Squares in Array Permutation
  • Find the occurrence of every element among all possible subarrays of the array
  • Compare Two Lists
  • Convert Number n to 1 in Minimum Steps
  • Generate All Distinct Subsequences of Length m from Numbers 1 to n with Repetitions
  • Default Parameters in Python Functions
  • Check if given string contains Even 1’s and Odd 0’s
  • Check if a Clique Can Be Divided into Two Equal Halves
  • Python Methods to Remove Spaces from Dictionary Values

Categories

  • Algorithms
  • Analysis
  • Arrays
  • Backtracking
  • Bit Magic
  • Blog
  • C
  • C Programs
  • C++
  • C++ Programs
  • Combinatorial
  • Compiler Design
  • Computer Networks
  • Computer Organization and Architecture
  • Data Structures
  • DBMS
  • Difference Between
  • Digital Logic
  • Divide and Conquer
  • Dynamic Programming
  • GATE CS
  • Git
  • Graph
  • Greedy
  • Hash
  • Heap
  • HTML
  • Internship
  • Interviews
  • Java
  • Java Programs
  • JavaScript
  • Linked List
  • Machine Learning
  • Mathematical
  • Matrix
  • Misc
  • MongoDB
  • MySQL
  • NoSQL
  • Operating Systems
  • Pattern Searching
  • Python
  • Python Programs
  • Queue
  • Recursion
  • Searching
  • Sorting
  • SQL
  • Stack
  • Strings
  • Tree
  • Web Technology

Meta

  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org
About Us | Contact | Feedback | Privacy Policy | Copyright
Sitemap