Skip to main content

92 docs tagged with "Sorting"

View all tags

3Sum losest (LeetCode)

Given an integer array nums of length n and an integer target, find three integers in nums such that the sum is closest to target.

Assign Cookies

This is a solution to the Assign Cookies problem on LeetCode.

Binary Array Sorting

This document provides solutions for sorting a binary array, where elements are either 0 or 1.

Bubble Sort

This tutorial covers the solution to the Bubble Sort problem from the GeeksforGeeks.

Car Fleet

Return the number of distinct groups of cars (car fleets) that reach the target mile together, where a fleet is formed when a faster car catches up to a slower car and they travel at the slower car's speed.

Contains Duplicate(LeetCode)

Given an integer array nums, return true if any value appears at least twice in the array, and return false if every element is distinct.

Fair Candy Swap

Find one pair of candy boxes, one from Alice and one from Bob, to swap so they both end up with the same total number of candies.

Find Triplet with Zero Sum

This document explores different approaches to solving the problem of finding a triplet in an array that sums up to zero, including solutions in JavaScript, TypeScript, Python, Java, and C++.

Friends Of Appropriate Ages

Calculate the total number of friend requests made between persons based on their ages, following specific conditions that determine when a friend request is not sent.

H-Index (LeetCode)

Given an array of integers citations where citations[i] is the number of citations a researcher received for their ith paper, return the researcher's h-index.

Harshad-Number

This is a solution to the Harshad Number problem on LeetCode.

Heaters

This is a solution to the heaters problem on LeetCode.

Height Checker

Given an array heights, return the number of indices where heights[i] != expected[i].

Insertion Sort

This tutorial covers the solution to the Insertion Sort problem from the GeeksforGeeks.

Kth Smallest

This tutorial covers the solution to the Kth Smallest problem from the GeeksforGeeks.

Largest Number(LeetCode)

Given a list of non-negative integers nums, arrange them such that they form the largest number and return it.

Longest Uncommon Subsequence II

Given an array of strings strs, return the length of the longest uncommon subsequence between them. If the longest uncommon subsequence does not exist, return -1.

Majority Element

Given an array nums of size n, return the majority element. The majority element is the element that appears more than ⌊n / 2βŒ‹ times. You may assume that the majority element always exists in the array.

Maximum Gap(LeetCode)

Given an integer array nums, return the maximum difference between two successive elements in its sorted form. If the array contains less than two elements, return 0.

maximum number of potholes that can be fixed

The given Solution class uses a greedy approach to maximize the number of potholes repaired within the given budget by prioritizing the repair of larger contiguous pothole segments first.

Maximum XOR With an Element From Array

Solve the problem of finding the maximum bitwise XOR of an element with given elements that do not exceed a specified value using trie and bit manipulation.

Merge Intervals(LeetCode)

Given an array of intervals where intervals[i] = [starti, endi], merge all overlapping intervals, and return an array of the non-overlapping intervals that cover all the intervals in the input.

Merge K Sorted Arrays

This tutorial covers the solution to the Merge K Sorted Arrays problem from the GeeksforGeeks.

Orderly Queue

Given a string s and an integer k, return the lexicographically smallest string that can be formed by repeatedly moving one of the first k characters of s to the end of the string.

Pancake Sorting

This is a solution to the Pancake Sorting problem on LeetCode.

Reducing Dishes

This document provides a solution to the Reducing Dishes problem, where we need to maximize the sum of the satisfaction of dishes.

Relative Ranks

This document provides solutions for the Relative Ranks problem.

Selection Sort

This tutorial covers the solution to the SelectionSort problem from the GeeksforGeeks.

Sort 0s, 1s And 2s

This tutorial covers the solution to the SSort 0s, 1s and 2s problem from the GeeksforGeeks website.

Sort Characters By Frequency (LeetCode)

Given a string s, sort it in decreasing order based on the frequency of the characters. The frequency of a character is the number of times it appears in the string.

Sort Characters By Frequency (LeetCode)

Given a string s, sort it in decreasing order based on the frequency of the characters. The frequency of a character is the number of times it appears in the string.

Sorted Matrix

This document covers methods to sort elements of a matrix in non-decreasing order in various programming languages.

Valid Anagram

This is a solution to the Valid Anagram problem on LeetCode.

Valid Square

This is a solution to the Valid Square problem on LeetCode.

Wiggle Sort II

This is a solution to the Wiggle Sort II problem on LeetCode.