You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
1.2 KiB
23 lines
1.2 KiB
---
|
|
id: sorting-searching
|
|
title: Sorting and searching
|
|
---
|
|
|
|
## Tips
|
|
|
|
When a given sequence is in a sorted order (be it ascending or descending), using binary search should be one of the first things that come to your mind.
|
|
|
|
## Sample questions
|
|
|
|
- Sorting search results on a page given a certain set of criteria.
|
|
- Sort a list of numbers in which each number is at a distance `K` from its actual position.
|
|
- Given an array of integers, sort the array so that all odd indexes are greater than the even indexes.
|
|
- Given users with locations in a list and a logged-in user with locations, find their travel buddies (people who shared more than half of your locations).
|
|
- Search for an element in a sorted and rotated array.
|
|
- [Source](http://blog.gainlo.co/index.php/2017/01/12/rotated-array-binary-search/)
|
|
- Merge two sorted lists together.
|
|
- Give 3 distinct algorithms to find the K largest values in a list of N items.
|
|
- Find the minimum element in a sorted rotated array in faster than O(n) time.
|
|
- Write a function that takes a number as input and outputs the biggest number with the same set of digits.
|
|
- [Source](http://blog.gainlo.co/index.php/2017/01/20/arrange-given-numbers-to-form-the-biggest-number-possible/)
|