Find words from characters - Leetcode - SAP ABAP || Algorithms and Data Structures

preview_player
Показать описание
Find all the words which can be formed using the characters given in the input in SAP ABAP ( Algorithms and data structures):

You are given an array of strings words and chars.
A string is good if it can be formed by characters from chars (each character can only be used once).
Return the sum of lengths of all good strings in words.

Edit: I haven't run the program in the video, i will put it in the github and share the link :)

Used the below as Input:
DATA(lt_words) = VALUE lt_w_struc( ( `coding` ) ( `apple` ) ( `google` ) ( `ashwanth` ) ( `pop` ) ).

DATA(lt_chars) = VALUE lt_c_struc( ( 'a' ) ( 'e' ) ( 'g' ) ( 'o' ) ( 'p' ) ( 'o' ) ( 'l' ) ( 'p' ) ( 'e' ) ( 'g' ) ).

Always welcome for any updates/changes for making algorithm even better :)
Рекомендации по теме
Комментарии
Автор

Just a thought, in your algorithm within the while loop, when the READ conditional fails why not EXIT from the LOOP. It would save a lot of processing (since you talk about complexities I am suggesting this 😉)

nvnarendran
Автор

using string operations it can be done bro

janagarsundaramoorthy
Автор

Hello Ashwanth, Kudos to your efforts in explaining the concepts in such simple and understandable way.
Could you please add your github link ?

sankariag
join shbcf.ru