Google Interview Question
Software Engineer / DevelopersCountry: India
Interview Type: In-Person
I just didn't find out any way to represent the database table in proper format, so i just used the <tr> tags!
I am representing here the table in horizontal format :
NAME : zac zac zac zac zac
LOCATION : california california california california california
Hello everyone,
I hope I got the solution for deleting the first two rows from Oracle table. Run below query in oracle
delete from emp where rowid in(select rd from(select aa.*, rowid rd from emp aa where rownum <3 order by rowid) abc) ;
Regards,
Note: Please correct/update me if found anything new
Psudocode(I will prefer to write it in C#, Python or Java because of the iterator constructs available, but choose language of your choice) :
Continue while (Counter_to_be_deleted)
1. We instantiate an iterator for the xml/json.
2. When you hit tr tag(tr tag encloses one record), delete the element, update counter_to_be_deleted = counter_to_be_deleted - 1
cant you just delete
2 of these rows?
<tr></tr>
<tr></tr>
done
tr means ROWS
hence the Table ROW initials TR
continuing you should do that for the database but we do not know what database you are using
mongodb?
mysql?
nosql/sql?
parse?
etc the syntax would be different depending on each one then.
do you want it in javascript or do you want it in php or
other backend languages what?
not enough information on what type of database is being used.
I am not sure if I have understood the question correctly but If we want to delete initial two rows from table we can use
- Anonymous May 07, 2014delete from table_name limit 2;
it will delete initial two rows.