g | x | w | all
Bytes Lang Time Link
019ARBLE240905T004250ZATaco
033F# .NET Core240904T222022Zdtanku
003Pyth240820T085825Zadrianus
035AWK240808T211310Zwobtax
033JavaScript Node.js240812T093345Zl4m2
00205AB1E240812T074834ZKevin Cr
005J240805T023006Zsouth
003Stack control240803T205004ZШвеев Ал
014K ngn/k240804T212950ZFmbalbue
022R240801T160236ZGiuseppe
015Ruby240731T180311Zint 21h
026Desmos240801T020454ZAiden Ch
019Kotlin 2.0.0240731T143136Zcolmmurp
022Perl 5 + 0513pF240728T204448ZDom Hast
015Perl 5 MListUtil=uniq pF240729T152917ZXcali
035Java 21240729T143539ZDavid Co
021R 4.4.0240729T090246ZSamR
065Setanta240728T205010Zbb94
038JavaScript Node.js240728T104100ZAndrew B
001Japt v2.0a0 h240728T183907ZShaggy
022Excel ms365240728T181455ZJvdV
003MATL240728T173544ZSuever
002Brachylog240728T154156ZUnrelate
002Jelly240728T154153ZJonathan
036Google Sheets240728T102209Zdoubleun
008Charcoal240728T135554ZNeil
005Haskell + hgl240728T134833ZWheat Wi
008Retina 0.8.2240728T134116ZNeil
004K ngn/k240728T133436Zakamayu
027PowerShell240728T121823Zuser3141
036Python 3240728T115156Zmatteo_c
015Arturo240728T112337Zchunes
003Uiua SBCS240728T105800Zchunes
026Python240728T102653Zxnor
024JavaScript ES6240728T101535ZArnauld
057C tcc240728T101650Zovs
002Vyxal 3240728T101335ZRubenVer
002APL Dyalog Vision240728T095611ZAdá
002Vyxal240728T095024Zemanresu

ARBLE, 19 bytes

index(-unique(l),1)

Try it online!

Per the challenge spec, takes a list of non-negative integers.

For 28 bytes, can take a string instead

index(-unique(split(s,1)),1)

Try it online!

F# (.NET Core), 33 bytes

let f s=s|>Seq.distinct|>Seq.last

Try it online!

Shame the lambda solution is the same length, would have been an easy golf.

Pyth, 3 bytes

e{z

Try it online!

e      take last element (implicit print)
 {z    deduplicate z (=input)

AWK, 39 35 bytes

awk -F '' '{for(;i++<NF;)s[$i]++?z:l=$i;$0=l}1'

Explanation:

Thanks to @Marius_Couet for shaving off several bytes.

JavaScript (Node.js), 33 bytes

s=>s.match(/(.)(?<!\1.+)/g).pop()

Try it online!

05AB1E, 2 bytes

Ùθ

Try it online.

Explanation:

Ù   # Uniquify the characters of the (implicit) input-string
 θ  # Pop and keep the last unique character
    # (which is output implicitly as result)

J, 5 bytes

_1{~.

Nothing new.

Attempt This Online!

_1{~.
   ~.   NB. nub removes duplicates
_1{     NB. take the last item

Stack control, 3 characters:

∪⟄⟸

Explanation:

∪ - union (removes all duplicates)
⟄ - pop last element from array
⟸ - hard shift (removes original array)

K (ngn/k), 14 bytes

{x@|/x?!1+|/x}

Try it online!

Explanation

{x@|/x?!1+|/x}
{            } function
       !1+     enumerate from 0 to
          |/x  the max element of the list
     x?        find every element index
   |/          pick the newest element index
 x@            index

R, 22 bytes

\(x)x[max(match(x,x))]

Attempt This Online!

A 1 byte longer solution than SamR's, but not implementation-dependent.

Ruby, 15 bytes

This version works with a list (conform to the rules):

->a{a.uniq[-1]}

Attempt This Online!

Ruby, 25 bytes

And this 25-bytes anonymous function takes a string as its input, splits in characters and outputs the last unique element:

->a{a.split('').uniq[-1]}

Attempt This Online!

Desmos, 26 bytes

f(L)=U[U.count]
U=L.unique

Try It On Desmos!

Try It On Desmos! - Prettified

Kotlin 2.0.0, 26 19 Bytes

{LinkedHashSet(it).last()}

A trivial port of David Conrad's Java solution. Expects a List<Char> and outputs a Char

{it.toSet().last()}

Saves 7 Bytes by using a Set instead of a LinkedHashSet. Sequence.toSet() preserves the original iteration order according to the docs

Try it Online

Perl 5 + -0513pF, 22 bytes

-3 bytes thanks to @Xcali!

$\=chop;/${\}/&&redo}{

Try it online!

Perl 5 -MList::Util=uniq -pF, 15 bytes

$_=(uniq@F)[-1]

Try it online!

Java 21, 35 bytes

s->new LinkedHashSet<>().getLast()

A Function<List<T>, T> for some T. Requires Java 21 which does not seem to be available yet on Try It Online or Attempt This Online.

R 4.4.0, 21 bytes

\(x)tail(unique(x),1)

Attempt This Online!

Takes as input a vector of utf-8 code points. Really not fancy, basically just a port of Arnauld's JS answer (and several others as well).

Although R's base::unique() is not documented to guarantee insertion order, the implementation will do so. It loops through every value of a vector in order and checks if it has been seen before, appending to a new vector any which have not been. While I suppose it's possible this implementation will not remain forever, it will work in R 4.4.0. Also, the git blame indicates this has been part of the R source for 26 years - I don't imagine it would be changed lightly in future versions.

Setanta, 65 bytes

gniomh(s){le i idir(fad@s-1,-1)ma i<=aimsigh@s(s[i]) toradh s[i]}

try-setanta.ie link

JavaScript (Node.js), 58 45 38 bytes

s=>[...s].map(a=e=>a[e]?0:a[e]=b=e)&&b

Try it online!

Japt v2.0a0 -h, 1 byte

â

Try it

Excel ms365, 22 bytes

=@TAKE(UNIQUE(A:A),-2)

enter image description here

MATL, 3 bytes

uJ)

Try it at matl.io

Explanation

     % Implicitly fetch input
u    % Find unique elements 
J)   % Get the last element
     % Print implicitly 

Brachylog, 2 bytes

dt

Try it online!

Nekomata, 2 bytes

ul

Attempt This Online!

More boring banal nub-tail solutions.

Jelly, 2 bytes

QṪ

A monadic Link that accepts a list and yields the newest element.

Try it online!

How?

QṪ - Link: list, A
Q  - deduplicate {A}
 Ṫ - tail {that}

Google Sheets, 36 bytes

=chooserows(unique(tocol(A:A,1)),-1)

64 bytes:

=+let(β,A:A,γ,sort(row(β)),sort(β,1=countifs(β,β,γ,"<="&γ),,γ,))

...or:

=chooserows(filter(A:A,1=map(A:A,lambda(β,countif(A1:β,β)))),-1)

Put the array in column A1:A and the formula in cell B1.

screenshot

Charcoal, 8 bytes

§θ⌈Eθ⌕θι

Try it online! Link is to verbose version of code. Explanation: Turned out to be a port of @xnor's answer.

    θ      Input string
   E       Map over characters
     ⌕     Index of
       ι   Current character
      θ    In input string
  ⌈        Take the maximum
§          Index into
 θ         Input string
           Implicitly print

Haskell + hgl, 5 bytes

gj<nb

Attempt This Online!

Explanation

Nub and get the last element.

Parser, 16 bytes

gk$(h'>~nxy)<*h'

Attempt This Online!

Since this challenge is pretty trivial to do using the normal library, I thought I'd try a parser only version.

Explanation

We create a parser which matches all characters that are not preceded by a copy of themselves.

The priority here is determined by h' with the longest parse having the highest priority.

Reflection

The normal version of this can't reasonably be improved. Improvements can be made based on the parser version, but it will never be on par with the other version for this task.

There are also some things I noticed which wouldn't save bytes here but should be done.

Retina 0.8.2, 8 bytes

D`.
!`.$

Try it online! Takes input as a string. Explanation:

D`.

Keep only the first of each duplicated character.

!`.$

Keep the last remaining character.

K (ngn/k), 4 bytes

The last *| unique ? element.

*|?:

Try it online!

PowerShell, 27 bytes

($args|% *ay|select -u)[-1]

Try it online!

Ungolfed:

($args | ForEach-Object -Member ToCharArray | Select-Object -Unique)[-1]

Converts the input string to a char array by calling the string's member "ToCharArray", then selecting only unique characters, and picking the last char.

Python 3, 36 bytes

f=lambda x:list({a:0for a in x})[-1]

Try it online!

Arturo, 15 bytes

$=>[last∪<=&]

running the code in arturo interpreter

Explanation

$=>[]  ; a function where input is assigned to &
last   ; last element of...
∪      ; union between...
<=&    ; input and itself              

This is two bytes shorter than last unique&, but requires the latest version for , hence it won't work online yet.

Uiua SBCS, 3 bytes

⊢⇌◴

Try it!

⊢⇌◴­⁡​‎‎⁡⁠⁣‏‏​⁡⁠⁡‌⁢​‎‎⁡⁠⁡‏⁠‎⁡⁠⁢‏‏​⁡⁠⁡‌­
  ◴  # ‎⁡deduplicate
⊢⇌   # ‎⁢last

Python, 26 bytes

lambda s:max(s,key=s.find)

Try it online!

Takes a string as input. s.find(c) outputs the first index in s where the character c appears, so using s.find as a key for max returns the character whose first occurrence in s comes latest.

JavaScript (ES6), 24 bytes

Note that it works because Set is guaranteed to maintain the insertion order of its elements.

s=>[...new Set(s)].pop()

Try it online!

Commented

s =>         // s = input string
[...         // turn into an array ...
  new Set(s) //   ... the set generated from s
             //       e.g. "BANANA" -> Set {'B','A','N'}
]            //
.pop()       // return the last element

C (tcc), 57 bytes

k;f(char*s){for(int v[128]={};*s;s++)k=v[*s]++?k:*s;k=k;}

Try it online!

Vyxal 3, 2 bytes

ut

try

APL (Dyalog Vision), 2 bytes

⊇∪

last unique

Vyxal, 2 bytes

Ut

Try it Online!

 t # last
U  # unique element