sonsy0929 / TIL

0 stars 0 forks source link

StringTokenizer Method #1

Open sonsy0929 opened 2 years ago

sonsy0929 commented 2 years ago

http://boj.kr/2142af44d2b441c799ea0a583f3d5b6a

    // linear time complexity
    public int countTokens() {
        int count = 0;
        int currpos = currentPosition;
        while (currpos < maxPosition) {
            currpos = skipDelimiters(currpos);
            if (currpos >= maxPosition)
                break;
            currpos = scanToken(currpos);
            count++;
        }
        return count;
    }