classSQL:def__init__(self,names:List[str],columns:List[int]):self.tables=defaultdict(list)definsertRow(self,name:str,row:List[str])->None:self.tables[name].append(row)defdeleteRow(self,name:str,rowId:int)->None:passdefselectCell(self,name:str,rowId:int,columnId:int)->str:returnself.tables[name][rowId-1][columnId-1]# Your SQL object will be instantiated and called as such:# obj = SQL(names, columns)# obj.insertRow(name,row)# obj.deleteRow(name,rowId)# param_3 = obj.selectCell(name,rowId,columnId)
classSQL{privateMap<String,List<List<String>>>tables;publicSQL(List<String>names,List<Integer>columns){tables=newHashMap<>(names.size());}publicvoidinsertRow(Stringname,List<String>row){tables.computeIfAbsent(name,k->newArrayList<>()).add(row);}publicvoiddeleteRow(Stringname,introwId){}publicStringselectCell(Stringname,introwId,intcolumnId){returntables.get(name).get(rowId-1).get(columnId-1);}}/** * Your SQL object will be instantiated and called as such: * SQL obj = new SQL(names, columns); * obj.insertRow(name,row); * obj.deleteRow(name,rowId); * String param_3 = obj.selectCell(name,rowId,columnId); */
1 2 3 4 5 6 7 8 910111213141516171819202122232425
classSQL{public:unordered_map<string,vector<vector<string>>>tables;SQL(vector<string>&names,vector<int>&columns){}voidinsertRow(stringname,vector<string>row){tables[name].push_back(row);}voiddeleteRow(stringname,introwId){}stringselectCell(stringname,introwId,intcolumnId){returntables[name][rowId-1][columnId-1];}};/** * Your SQL object will be instantiated and called as such: * SQL* obj = new SQL(names, columns); * obj->insertRow(name,row); * obj->deleteRow(name,rowId); * string param_3 = obj->selectCell(name,rowId,columnId); */
typeSQLstruct{tablesmap[string][][]string}funcConstructor(names[]string,columns[]int)SQL{returnSQL{map[string][][]string{}}}func(this*SQL)InsertRow(namestring,row[]string){this.tables[name]=append(this.tables[name],row)}func(this*SQL)DeleteRow(namestring,rowIdint){}func(this*SQL)SelectCell(namestring,rowIdint,columnIdint)string{returnthis.tables[name][rowId-1][columnId-1]}/** * Your SQL object will be instantiated and called as such: * obj := Constructor(names, columns); * obj.InsertRow(name,row); * obj.DeleteRow(name,rowId); * param_3 := obj.SelectCell(name,rowId,columnId); */