TÓPICO

Javascript - Wrong answer (0%) URI - 1068

Luiz_Felipe_ perguntou 2 years ago

Não sei por que ta dando esse erro, afinal nem faz sentido para mim. Já que nas definições das respostas tá escrito que a porcentagem é quão errado está a saída esperada.

Se for tentar ler o código tenta compiar e colar no editor de texto e manda o editor formatar já que o uri desfaz a indentação.

Tá ai o código quem puder me ajudar. Agradeço.

var input = require('fs').readFileSync('/dev/stdin', 'utf-8'); var lines = input.split("\n");

class Stack { constructor() { this.items = {}; this.count = 0; }

isEmpty() { return this.count === 0; }

push(element) { this.items[this.count] = element; this.count++; }

pop() { delete this.items[this.count - 1]; this.count--; }

clear() { this.count = 0; this.item = {}; }

verifyParens(expression) { for (let char of expression) { if (char === '(') { this.push(char); } if (char === ')') { if (this.isEmpty()) { console.log('incorrect'); return; } this.pop(); } } if (this.isEmpty()) { console.log('correct'); } if (!this.isEmpty()) { console.log('incorrect'); this.clear(); } }

verify(array) { for (let i = 0; i < array.length; i++) { this.verifyParens(array[i]); } } }

const stack = new Stack();

stack.verify(lines);

Este tópico ainda não foi respondido. Seja o primeiro!

Lembre de não publicar soluções. Sua publicação pode ser revisada por nossos moderadores.