Sort a Linked List of 0s, 1s and 2s | Programming Tutorials

preview_player
Показать описание
Given a linked list which only consists of 0s, 1s and 2s. Write a code to sort a linked list. In this tutorial, I have explained how to sort a linked list in O(n) time complexity using java code.



Example 1:

Input: 2 -- 0 -- 1 -- 0 -- 2 -- 0 -- 1 -- NULL
Output: 0 -- 0 -- 0 -- 1 -- 1 -- 2 -- 2 -- NULL
Рекомендации по теме
Комментарии
Автор

hello sir can we use #Collections.sort() ?

ravikant-pal
join shbcf.ru