Algorithm/DS Problem#1: Find the relative order of records

Problem Statement: You are given a set of records with keys and you need to find out the relative order of keys.
records=[[‘k1’,’k2',’k5'],[‘k0’,’k2',’k3'],[‘k4’,’k5',’k6']]

Output: [‘k1’, ‘k0’, ‘k4’, ‘k2’, ‘k5’, ‘k3’, ‘k6’] or [‘k4’, ‘k0’, ‘k1’, ‘k2’, ‘k5’, ‘k3’, ‘k6’]

You are expected to keep the order intact in the output. k1 should come before k2 and k0 also should come before k2.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
svalak

svalak

Passionate about problem solving; #WritesOnQuora #VoraciousReader #MBTIEnthusiast #LovePsychology https://www.quora.com/profile/Shaila-Hegde-2