v1
4/29/2025 by kap80 -00
Setup HTML - click to add setup HTML
disable setup JavaScript
Setup JavaScript
const alphabet = "abcdefghijklmnopqrstuvwxyz";

const start = 'X' + alphabet.repeat(100);
const middle = alphabet.repeat(50) + 'X' + alphabet.repeat(50);
const end = alphabet.repeat(100) + 'X';

function firstNonRepeatingChar(str) {
  for (let i = 0; i < str.length; i++) {
    if (str.indexOf(str[i]) === str.lastIndexOf(str[i])) {
      return str[i]
    }
  }

  return null
}

function firstNonRepeatingCharV2(str) {
  const seen = new Set()

  for (let i = 0; i < str.length; i++) {
    const char = str[i]

    if (seen.has(char)) {
      continue
    }

    if (i === str.lastIndexOf(char)) {
      return char
    }

    seen.add(char)
  }

  return null
}

delete caserun single casemove downdrag and drop case


ready



firstNonRepeatingChar(start);
firstNonRepeatingChar(middle);
firstNonRepeatingChar(end);
delete caserun single casemove updrag and drop case


ready



firstNonRepeatingCharV2(start);
firstNonRepeatingCharV2(middle);
firstNonRepeatingCharV2(end);
Test Case - click to add another test case
Teardown JS - click to add teardown JavaScript
Output (DOM) - click to monitor output (DOM) while test is running
RUN