function u = DDM(A,b,IndexyVnitrnichUzlu,IndexyHranicnichUzlu,Sstriska)

N = max(size(IndexyVnitrnichUzlu));
uP = zeros(length(b),1);
uH = zeros(length(b),1);

% Krok 1
for i=1:N
    IndexyVnitrnichUzlui = IndexyVnitrnichUzlu{i};
    AI = A(IndexyVnitrnichUzlui,IndexyVnitrnichUzlui);
    bI = b(IndexyVnitrnichUzlui);
    uP(IndexyVnitrnichUzlui) = AI\bI;
end

% Krok 2
c = b(IndexyHranicnichUzlu);
for i=1:N
    IndexyVnitrnichUzlui = IndexyVnitrnichUzlu{i};
    B = A(IndexyHranicnichUzlu,IndexyVnitrnichUzlui);
    c = c - B*uP(IndexyVnitrnichUzlui);
end
uH(IndexyHranicnichUzlu) = Sstriska\c;

% Krok 3
for i=1:N
    IndexyVnitrnichUzlui = IndexyVnitrnichUzlu{i};
    AI = A(IndexyVnitrnichUzlui,IndexyVnitrnichUzlui);
    B = A(IndexyHranicnichUzlu,IndexyVnitrnichUzlui);
    d = -B'*uH(IndexyHranicnichUzlu);
    uH(IndexyVnitrnichUzlui) = AI\d;
end

u = uP+uH;