codolove's blog

By codolove, history, 8 years ago, In English

I was trying to solve Another Problem On Strings using two pointers since it was mentioned in its tags but I am not getting an idea of it. I have solved it by using hashing and binary search by considering the prefix sum. It will be helpful if one can give some idea of approaching it with two pointers.

Full text and comments »

  • Vote: I like it
  • +3
  • Vote: I do not like it

By codolove, history, 8 years ago, In English

I was trying to solve this problem on spoj that involves LCS with some other constraints. I have come with a recursive solution which gives correct answer on all cases. But when I try to memoziate it, it gives wrong answer. I am not able to figure out why it gives wrong answer on memoziation. my code is here with explanation.

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it

By codolove, history, 9 years ago, In English

I am trying to solve this on spoj. I have first precomputed the index for both the case(appending number to beginning and appending number to end). Then, I used top down approach to find the minimum value. It works on most test cases but gives wrong answer on spoj. I am not able to figure out the reason. Please help. My Soloution

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it

By codolove, 9 years ago, In English

Problem I am trying to solve this problem by finding the region to which x or y belong. I am maintaining a set of all the regions that are available. First, I find to which set x or y belong and delete that set. Two new sets are created. I am keeping the "cut distance" in a set container. But I am getting TLE on test case 11. I ma using only logarithmic data structures. My Code

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it

By codolove, 9 years ago, In English

I am trying to create a link list. I wanted to know how these two codes are different? Code1: if (start == NULL) { start = newnode; } else { temp = start; while(temp != NULL) { temp = temp->next; }

temp = newnode;

}

Code2: if (start == NULL) { start = newnode; } else { temp = start; while(temp->next != NULL) { temp = temp->next; }

temp->next = newnode;
    }

}

Full text and comments »

  • Vote: I like it
  • +6
  • Vote: I do not like it

By codolove, 9 years ago, In English

I am trying to solve this problem on spoj where we have to output those words which have a certain prefix in it. I used trie data structure for it. But I am getting wrong answer again and again. My solution is here.

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it

By codolove, 9 years ago, In English

I was trying to apply the divide and conquer algorithm for closest pair of points on this problem. I have been getting wrong answer many times. My solution is here. I read this algorith from this site.

Full text and comments »

  • Vote: I like it
  • +6
  • Vote: I do not like it

By codolove, 9 years ago, In English

I am trying to solve this question from many days but getting wrong answe always. I am using a trie to solve this. My code is here.

Full text and comments »

  • Vote: I like it
  • +9
  • Vote: I do not like it