About 240,000 results
Open links in new tab
  1. How to Sort an Array in C++? - GeeksforGeeks

    Oct 10, 2024 · In this article, we will learn how to sort an array in C++. Example: C++ STL provides std::sort () method which is used to sort the array in any desired order. This function uses a combination of quicksort, insertion sort and heapsort algorithm.

  2. Arrays for Competitive Programming - GeeksforGeeks

    May 21, 2024 · Hashing using arrays is widely used in competitive programming. If all the array values are within the range of the size of the array, then array can be used for hashing key-value pairs, providing O(1) complexity for each operation i.e. fetch and update. C++

  3. c++ - The Fastest Sorting function - Stack Overflow

    Mar 3, 2010 · Use the std::sort function which typically defaults to quicksort (but deals with the ugly edge cases of e.g. a fully sorted array taking O (n^2) time).

  4. Sort an Array Containing 1 to N Values - Online Tutorials Library

    Mar 19, 2025 · Sorting an array containing values from 1 to n means arranging the integers in their natural ascending order. This type of sorting problem is commonly encountered in competitive programming (for solving complex problems), where the array is guaranteed to have integers ranging from 1 to n.

  5. Sorting of array in C++ (All Methods) - PrepInsta

    There are many sorting techniques to sort the array-like quick sort, merge sort, bubble sort, and insertion sort them is scripted below. Here on this page, we are going to discuss the selection for sorting an array in C++. Take the size of the array from the user. Declare an array of given input size. Take the input of all elements of the array.

  6. sorting - How to use std::sort to sort an array in C++ - Stack Overflow

    Mar 12, 2017 · To sort arrays with std::sort() std::sort(nums, nums+size); So, we need size, either we can deduce with and pass to the sort_nums method, or we can call std::sort in the main function. unsigned int size{sizeof(nums)/nums[0]};

  7. Main Page - Algorithms for Competitive Programming

    Apr 17, 2024 · Algorithms for Competitive Programming¶ The goal of this project is to translate the wonderful resource https://e-maxx.ru/algo which provides descriptions of many algorithms and data structures especially popular in field of competitive programming.

  8. Solved Questions Competitive Programming | PDF | Array Data …

    Specific questions summarized include: 1. Calculating the product array of a given array without using division. 2. Finding the kth element in two sorted arrays merged together. 3. Computing the factorial of a large number by storing each digit in an array. 4. Determining the number of trailing zeros in a factorial by counting factors of 5 and 10.

  9. competitive-programming-cheatsheet

    Sorting. Problems: this is used in problems where sorting will make it easier to compare/find something. Time complexity: O(n * log n) Example problem: Kayaking; Greedy algorithms. Description: greedy algorithms are those which always make the locally optimal choice at each stage of the problem.

  10. C++ for Competitive Programming - Tips and Best Practices

    Mar 14, 2025 · Use efficient data structures: Choose the right data structure for the problem (e.g., vector for dynamic arrays, set for sorted data). Handle edge cases : Consider boundary conditions and invalid inputs.

Refresh