Find Largest Word in Dictionary by Deleting Some Characters of Given String in Ruby
In this guide, you will learn how to implement a method to find if a string is subsequence of another string or not and if so, return the longest word of the given string that is a subsequence.
Guide Tasks
  • Read Tutorial
  • Complete the Exercise

Summary

Define a method that can figure out what is the largest dictionary word in a given string.

Exercise Description

Build out a method that can successfully take in a list of dictionary words and a given string of characters, figure out which of the listed words could possibly be made from the string given, and then print out the longest word that was found.

Examples

  dict = {"ale", "apple", "monkey", "plea"}   
  str = "abpcplea"  
# Output : apple 

Real World Usage

This exercise will help you understand subsequence and how to correctly implement a method that analyzes a given string of characters and a list of dictionary words and delete some characters of the string in order to figure out which of the words is the largest subsequence of the string.

Test Cases

Code File