EntityID = int
Entity = {
type : ‘file’ | ‘directory’
name : String
Children : Collections of files/directory
Size : int
}
root (ID : 2) :
dir (ID : 1) :
file (ID : 3 ) : size = 200b
file (ID : 4 ) : size = 100b
file (ID : 5) : size = 300b
So here the size of entityId=2 which is root is (200 + 100 + 300) which is 600b
FileSystem : HashMap<EntityID, Entity>
FileSystem : { 1 : {type='dir', name='dir', children=[1,5]},
2 : {type='dir', name='root', children=[3,4]},
3 : {type='file', name='file', size=200b},
4 : {type='file', name='file', size=100b},
5 : {type='file', name='file', size=300b}}I was able to solve this and was able to give answer for the follow ups as well. But I don't know what went wrong.
Feedback was given as borderline in some areas and good in some areas.
Do upvote if you find this information useful :-)