2/23

First Non-Repeating Character

Medium

Given a string S, find the first character that does not repeat in the string.

If every character appears more than once, return null.


Example

Suppose the input is:

ri!s: "SWISS"

The characters are:

S → 3 times
W → 1 time
I → 1 time

Since W is the first character that appears only once, the expected output is:

"W"


ri! Rule Inputs

ri!sText
"SWISS"

Example 1 — Case 1

Input: ri!s
"SWISS"
Output:
W

Example 2 — Case 2

Input: ri!s
"AABBCCD"
Output:
D

Example 3 — Case 3

Input: ri!s
"AABBCC"
Output:
null

Appian Expression Tips

  • • Use ri!variableName for rule inputs
  • • Use a!localVariables(local!x: …, body) for locals
  • • Use a!forEach(items: …, expression: fv!item) to iterate
  • • Use where() / reject(fn!isnull, list) to filter