class Solution {
public:
vector<ListNode*> rehashing(vector<ListNode*> hashTable) {
int n = hashTable.size(), m=n*2;
vector<ListNode*> res(m, NULL);
for(int i=0;i<n;i++){
ListNode* cur = hashTable[i];
while(cur){
int val = cur->val;
ListNode* node = new ListNode(val);
int index = val<0 ? (val%m+m)%m : val%m;
ListNode* ccur = res[index];
if(!ccur) res[index]=node;
else{
while(ccur->next){
ccur = ccur->next;
}
ccur->next = node;
}
cur = cur->next;
}
}
return res;
}
};