Asked a slight variation of this problem for OA at Amazon  ¯\_(ツ)_/¯ See edit
EDIT*I took Amazon OA a while back and I was asked a variation of this question. it was a slight modification to this problem.\nit was count all unique contiguo
EDIT**I took Amazon OA a while back and I was asked a variation of this question. it was a slight modification to this problem.\nit was count all unique contiguous subarray characters to get a score. I was able to pass all test cases on OA with code at bottom*\nLEETCODE should be 105, not 92.\nHad online Amazon  assessment today and was asked this question, and I got it right.\n\npassed all test cases.\nfor assessment\n\nNiave solution failed a few test cases for time limit:\n\n\tdef uniqueLetterString(s):\n \xA0 \xA0def uniqueLetters(s):\n        count = 0\n        seen = set()\n        for c in s:\n            if c not in seen:\n                seen.add(c)\n                count +=1\n        return count\n\n    total = 0\n    for i in range(len(s)):\n        for j in range(i,len(s)):\n            total += uniqueLetters(s[i:j+1])\n    return total\n    \n #DP solution passed all test cases\n\n\tdef uniqueLetterString(s: str) -> int:\n\t\t\t\n\t\t\ttotal = 0\n\t\t\tcurrent = 0\n\t\t\tfor i in range(len(s)):\n\t\t\t\tprev = 0\n\t\t\t\tlastpos = [-1 for i in range(26)]\n\t\t\t\tfor j in range(i,len(s)):\n\t\t\t\t\tkey = ord(s[j]) - ord(\'A\')\n\t\t\t\t\tif i == j:\n\t\t\t\t\t\tcurrent = 1\n\n\t\t\t\t\telif lastpos[key] == -1:\n\t\t\t\t\t\tcurrent = prev +1\n\t\t\t\t\telse:\n\t\t\t\t\t\tcurrent = prev\n\t\t\t\t\tlastpos[key] = j\n\t\t\t\t\ttotal += current\n\t\t\t\t\tprev = current  \n\t\t\t\t\t#print(f"Unique Characters: {current} Total {total}  {s[i:j+1]}")\n\t\t\treturn total\n\nPrintout of LEETCODE\n\n\tUnique Characters: 1 Total 1  L\n\tUnique Characters: 2 Total 3  LE\n\tUnique Characters: 2 Total 5  LEE\n\tUnique Characters: 3 Total 8  LEET\n\tUnique Characters: 4 Total 12  LEETC\n\tUnique Characters: 5 Total 17  LEETCO\n\tUnique Characters: 6 Total 23  LEETCOD\n\tUnique Characters: 6 Total 29  LEETCODE\n\tUnique Characters: 1 Total 30  E\n\tUnique Characters: 1 Total 31  EE\n\tUnique Characters: 2 Total 33  EET\n\tUnique Characters: 3 Total 36  EETC\n\tUnique Characters: 4 Total 40  EETCO\n\tUnique Characters: 5 Total 45  EETCOD\n\tUnique Characters: 5 Total 50  EETCODE\n\tUnique Characters: 1 Total 51  E\n\tUnique Characters: 2 Total 53  ET\n\tUnique Characters: 3 Total 56  ETC\n\tUnique Characters: 4 Total 60  ETCO\n\tUnique Characters: 5 Total 65  ETCOD\n\tUnique Characters: 5 Total 70  ETCODE\n\tUnique Characters: 1 Total 71  T\n\tUnique Characters: 2 Total 73  TC\n\tUnique Characters: 3 Total 76  TCO\n\tUnique Characters: 4 Total 80  TCOD\n\tUnique Characters: 5 Total 85  TCODE\n\tUnique Characters: 1 Total 86  C\n\tUnique Characters: 2 Total 88  CO\n\tUnique Characters: 3 Total 91  COD\n\tUnique Characters: 4 Total 95  CODE\n\tUnique Characters: 1 Total 96  O\n\tUnique Characters: 2 Total 98  OD\n\tUnique Characters: 3 Total 101  ODE\n\tUnique Characters: 1 Total 102  D\n\tUnique Characters: 2 Total 104  DE\n\tUnique Characters: 1 Total 105  E\n\n\t\n\t
[]