# Unique String

Check if string made of unique ASCII characters

```
public class Solution {
  // private final static int NUM_DISTINCT_CHARS = 256; // change as appropriate for unicode

  public boolean allUnique(String word) {
    // int numBoxes = Math.ceil(NUM_DISTINCT_CHARS / 32);
    int[] vec = new int[8]; // UNICODE_CHAR_AMOUNT / 32
    char[] array = word.toCharArray();
    for (char c : array){
      if ((vec[c / 32] >> (c % 32) & 1) != 0)return false; 
      vec[c / 32] |= 1 << (c % 32); //at c / 32 index, set bit to c % 32 with OR EQUAL
    }
    return true;
  }
}

```

TC: O(N)

SC: O(N)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://llssff.gitbook.io/coding-problems/bit-operations/unique-string.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
