Salesforce Interview Question for Software Developers


Country: United States
Interview Type: Written Test




Comment hidden because of low score. Click to expand.
0
of 0 vote

Can anyone help me

- asrikanth.125 November 18, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

File system is basically a tree. So your root node is your root folder. Each folder needs to be have map with name of the subdirectories.
Since we change directories we need to keep reference to current directory and have ability to traverse to its parent for 'up' command.
So directory can be represented as a class with reference to its parent object (parent will be null for the root) and its map of sub directories.

Command that needs to be handled:
dir -> print element of current node's map
mkdir -> create element in map. Entry in the map should be object of class node and should have reference to current node as a parent.

if map already contains that entry with the key -> subdirectory already exists

cd -> change current node value
Find entry in map of current with name of directory you want to cd into.
if map doesn't contain entry with that name -> subdirectory doesn't exist.
if exists then change current node
up -> change current node value
Check if parent reference is null
if null -> cannot move up the root directory
else change current node to its parent.

- sp786 November 20, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

I think it is easy to use Trie in this case. Define trie with maps, where each value in map is an entity (file or directory). Maintain a stack (say currPath) at class level which serves as current path of the cursor (pwd in unix). so if you want to create a file or directory, go in the depth of trie and when path is equal to currPath, do the intended operation.

- getPDat January 10, 2019 | Flag Reply


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More