Linked List in Java - 82: Compare two strings represented as linked lists

preview_player
Показать описание

Solution:
- We've two string list of characters, so compare one by one each node value
- If at any point, first list value is smaller than second list value, return -1
- If at any point, second list value is smaller than first list value, return 1
- At last, if both list is null, return 0 as both are equal
- At last, if head1 is null but head2 is not null return -1
- At last, if head1 is not null but head2 is null return 1
- Time Complexity: O(n)
- Space Complexity: O(1) as we're taking only constant variables

Please check video for more info:

This problem is similar to:
Compare two strings represented as linked lists in java,
how to Compare two strings represented as linked lists,
Compare two strings represented as linked lists,
Compare two string,
Compare characters of two string,
linked list,
tutorial,
coding simplified,
java

CHECK OUT CODING SIMPLIFIED

★☆★ VIEW THE BLOG POST: ★☆★

I started my YouTube channel, Coding Simplified, during Dec of 2015.
Since then, I've published over 400+ videos.

★☆★ SUBSCRIBE TO ME ON YOUTUBE: ★☆★

★☆★ SEND EMAIL At: ★☆★
Рекомендации по теме
Комментарии
Автор

Will this work for 1st string 'evz' and 2nd string 'evebc'?

soniabharti
visit shbcf.ru