Posts

Showing posts with the label Introduction to sets in python

Introduction to sets in Python - HackerRank solution

Solution for hackerRank problem Find a string in python Problem : A  set  is an unordered collection of elements without duplicate entries. When printed, iterated or converted into a sequence, its elements will appear in an arbitrary order. >>> print set() set([]) >>> print set('HackerRank') set(['a', 'c', 'e', 'H', 'k', 'n', 'r', 'R']) >>> print set([1,2,1,2,3,4,5,6,0,9,12,22,3]) set([0, 1, 2, 3, 4, 5, 6, 9, 12, 22]) >>> print set((1,2,3,4,5,5)) set([1, 2, 3, 4, 5]) >>> print set(set(['H','a','c','k','e','r','r','a','n','k'])) set(['a', 'c', 'r', 'e', 'H', 'k', 'n']) >>> print set({'Hacker' : 'DOSHI', 'Rank' : 616 }) set(['Hacker', 'Rank']) >>> print set(enumerate(['H',&#