Question: Write a static method named problem 2 that accepts a string and a positive integer k . Find and return a list with any k

Write a static method named problem2 that accepts a string and a positive integer k. Find and return
a list with any k distinct characters. If k is greater than the length of the given string, return all the
distinct characters. You cannot use the collections module to solve this problem.
Call the function with the test case and display the return result.
Test case: if the given string is aaabbbcccdddeeefffggg and k =5, your function should return any
five distinct characters, e.g.,[a,b,c,d,e].

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!