anonymous
BAN USER- 0of 0 votes
AnswersYou have a single string which contains all the positive numbers upto N concatenated together. If you are given an input number then how would you find the index position of the number in the string.
Eg:String str = "12345678910111213141516171819202122232425......upto 10000"; input = 20 should return the index of 20 in the string which is 29
The example string is upto 10000. The actual string can be upto any number N.
- anonymous in United States| Report Duplicate | Flag | PURGE
Amazon SDE1 String Manipulation - 0of 0 votes
AnswersI have an unordered array of nodes. Each node has an id and parent_id. I want to pretty print out the nodes in an expanded format.
Assumptions:
There is only one root node in the array.
Don't worry about the white space.
Node has a toString() method.
All the ids are arbitrary and unique.
This is a tree and not a graph.
For example:
Sample input:
[{parentId: F, id:G}, {parentId: E, id: F}, {parentId: A, id: B}...]A (parent_id = null) B (parent_id = A) C (parent_id = B) D (parent_id = C) H (parent_id = B) E (parent_id = A) F (parent_id = E) G (parent_id = F)
Sample output:
- anonymous in United States
ABCDHEFG
Please write a more optimized solution and tell me the complexity.| Report Duplicate | Flag | PURGE
unknown Software Engineer / Developer Data Structures - 0of 0 votes
AnswersI have an unordered array of nodes. Each node has an id and parent_id. I want to pretty print out the nodes in an expanded format.
- anonymous in United States
Assumptions:
There is only one root node in the array.
Don't worry about the white space.
Node has a toString() method.
All the ids are arbitrary and unique.
This is a tree and not a graph.
For example:
Sample input:
[{parentId: F, id:G}, {parentId: E, id: F}, {parentId: A, id: B}...]
A (parent_id = null)
B (parent_id = A)
C (parent_id = B)
D (parent_id = C)
H (parent_id = B)
E (parent_id = A)
F (parent_id = E)
G (parent_id = F)
Sample output:
ABCDHEFG
Please tell me the naive solution and its complexity.
Please write a more optimized solution and tell me the complexity.| Report Duplicate | Flag | PURGE
unknown Software Engineer / Developer
Repnancysimms14, Backend Developer at ASAPInfosystemsPvtLtd
I am Nancy from California,Handling project development and documentation is my job. Passionate determined.Looking for an open project ...
Actually the string can be upto any number N. Edited the question.
- anonymous January 07, 2014