You are not logged in. Please login at www.codechef.com to post your questions!

×

SPOJ EDIST Problem

Problem : Click here

My Code :: ....

Blockquote

#include <bits stdc++.h=""> using namespace std; int main() { int t; cin>>t; while(t--) { string A,B; cin>>A>>B; char w='q'; long int a=A.size(),b=B.size(); long int c=max(a,b),d=min(a,b),z=0; for(int i=0;i<a;i++) { for(int j=0;j<b;j++) { if(A.at(i)==B.at(j) && A.at(i)!=w && B.at(j)!=w) { z++; A.at(i)=w; B.at(j)=w; } } } cout<<c-z<<endl; } return 0; }

Blockquote

........... I am new to Programming ! :/ .. So anyone please explain where i have gone wrong ? Comments in the problem say that this problem requires dp. i donno dp :( (as i am new ) ! if this can't be solved in the way i did and compulsorily requires dp. Suggest me link to learn . Thanks in advance !!.

asked 08 Dec '14, 17:41

vsukeeshbabu's gravatar image

2★vsukeeshbabu
78727
accept rate: 0%


This is a standard DP problem. take a look at this link

http://www.geeksforgeeks.org/dynamic-programming-set-5-edit-distance/

link

answered 08 Dec '14, 18:37

piyush_2012's gravatar image

2★piyush_2012
11
accept rate: 0%

toggle preview
Preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:

×2,212
×1,137
×8
×6

question asked: 08 Dec '14, 17:41

question was seen: 4,559 times

last updated: 08 Dec '14, 18:40