0

Is there a way to convert a linked list to a string?

I have a linkedlist of sentences and another linkedlist of words. I want to check the sentences linkedlist for the words in the words linkedlist and was thinking a good approach would be to convert the words linked list to a string.

23rd Nov 2021, 7:48 PM
Isang-Ofon Udo-Arthur
Isang-Ofon Udo-Arthur - avatar
6 odpowiedzi
+ 11
Isang-Ofon Udo-Arthur , it would be helpful if can mention the programming language and also show us your attempt. thanks!
23rd Nov 2021, 8:01 PM
Lothar
Lothar - avatar
+ 6
Isang-Ofon Udo-Arthur , [edited] you can do this with 2 nested loops. use the outer loop to iterate through the sentences, and the inner loop to iterate through the words. so you are able to check if a word is a substring of a sentence.
23rd Nov 2021, 8:40 PM
Lothar
Lothar - avatar
+ 6
Isang-Ofon Udo-Arthur , we can create a string from a list by using: (e.g from the word list) .... string newStr = string.Join( " ", word); // instead of using " " as a separator for the new string, we can use other separators like "," ... Console.WriteLine(newStr); ....
24th Nov 2021, 10:27 AM
Lothar
Lothar - avatar
+ 1
Sorry about that. In C#
23rd Nov 2021, 8:23 PM
Isang-Ofon Udo-Arthur
Isang-Ofon Udo-Arthur - avatar
0
C# Is there a way to convert a linked list to a string? I have a linkedlist of sentences and another linkedlist of words. I want to check the sentences linkedlist for the words in the words linkedlist and was thinking a good approach would be to convert the words linked list to a string.
23rd Nov 2021, 8:24 PM
Isang-Ofon Udo-Arthur
Isang-Ofon Udo-Arthur - avatar
0
Thanks. I will look at that approach. But I'll still like to know if there's way changed a linkedlist to a single string
23rd Nov 2021, 10:35 PM
Isang-Ofon Udo-Arthur
Isang-Ofon Udo-Arthur - avatar