URI Online Judge Solution 1191 Tree Recovery- Solution in C, C++, Java, Python and C# - Online Judge Solution

Latest

It is a free Online judges problems solution list. Here you can find UVA online Judge Solution, URI Online Judge Solution, Code Marshal Online Judge Solution, Spoz Online Judge Problems Solution

Tuesday, September 19, 2017

URI Online Judge Solution 1191 Tree Recovery- Solution in C, C++, Java, Python and C#

URI Online Judge Solution 1191 Tree Recovery- Solution in C, C++, Java, Python and C#

URI Online Judge Solution 1191 Tree Recovery | Beginner
URI Problem Link - https://www.urionlinejudge.com.br/judge/en/problems/view/1191

Problem Name: 1191 Tree Recovery solution
Problem Number : URI - 1191 Tree Recovery solution
Online Judge : URI Online Judge Solution
Category: Graph
Solution Language : C,C plus plus, java, python, c#(c sharp)

URI Online Judge Solution 1191 Tree Recovery- Solution in C, C++, Java, Python and C#

URI 1191 problem simple input and output

Input SampleOutput Sample
DBACEGF ABCDEFG
BCAD CBAD
ACBFGED
CDAB

URI Solution 1191 Tree Recovery Code in C++ / URI 1191 in cpp:


#include <iostream>
#include <cstring>

using namespace std;

int curr;

void foo(string prefixa, string infixa, int i, int j) {
  if(i <= j) {
    curr++;
    int pos = infixa.find(prefixa[curr]);
    foo(prefixa, infixa, i, pos - 1);
    foo(prefixa, infixa, pos + 1, j);
    cout << infixa[pos];
  }
}

int main(int argc, char const *argv[]) {
  string pre, in;

  while(cin >> pre >> in) {
    curr = -1;
    foo(pre, in, 0, pre.size() - 1);
    cout << "\n";
  }

  return 0;
}

URI Solution 1191 Tree Recovery Code / URI 1191 solution in Java:



URI Solution 1191 Tree Recovery Code / URI 1191 solution in  Python:

URI Solution 1191 Tree Recovery Code / URI 1191 solution in  C# (C Sharp):


Demonstration:

Just implement this in coding. Since having any problem just put a comment below. Thanks



Tags: URI Online Judge Solution, URI OJ Solution list, URI Problems Solution, URI solver, URI all problem solution list, URI 1191 code in C, URI 1191 Tree Recovery code in C++, URI 1191 Tree Recovery solution in C, URI solution, URI 1191 Tree Recovery solution in C,URI 1191 Tree Recovery solution in C++-CPP,URI 1191 Tree Recovery solution in C# (C sharp),URI 1002 solution in Java,URI 1191 Tree Recovery solution in Python,

No comments:

Post a Comment