surajkvm007's blog

By surajkvm007, history, 9 years ago, In English

The following question was asked to my friend in an interview : given a string consisting only of '(' and ')'. find total number of substrings with balanced parenthesis Note: the input string is already balanced.

The only solution i can think of this problem is brute force which takes n^3 time. Is there a faster solution possible.If there is then i would also like to know the build up to that approach.

Full text and comments »

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

By surajkvm007, history, 9 years ago, In English

can anyone please provide me with a hint to solve this problem

basically we need to find all the cliques in the graph but in short time.

Update : I tried Bron-Kerbosch algorithm but it takes exponential time and the time limit for the problem is 1 sec with maximum of 128 vertices.

Full text and comments »

  • Vote: I like it
  • -4
  • Vote: I do not like it

By surajkvm007, history, 9 years ago, In English

Given a forest with n vertices, add edges to make it into a tree with minimal diameter. I tried many approaches but none of them passed system test cases.Please suggest some algorithm to solve this problem.

Full text and comments »

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

By surajkvm007, 10 years ago, In English

i tried to solve codeforces gym problems of a finished round but i am not seeing any option to submit my solution can anyone please help me in this matter

Full text and comments »

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

By surajkvm007, 11 years ago, In English

please name some good books on data structures and algorithms with good problem set

Full text and comments »

  • Vote: I like it
  • -18
  • Vote: I do not like it

By surajkvm007, 11 years ago, In English

i want to know the basic stratey for solving this problem

Full text and comments »

  • Vote: I like it
  • -24
  • Vote: I do not like it