Algo.Java.LoopSpeed

Interesting observation !

looking at leetcode tests with different algos, looks like for in with iterator inside works faster than for i

        // this loop works faster rather than for i loop
        for (char c: moves.toCharArray()) {
            fq[c - 'A']++;
        }
//        for (int i = 0; i < moves.length(); i++) {
//            fq[moves.charAt(i) - 'A']++; // decreasing A,because A has a minimal alphabet code = 65
//        }
This entry was posted in Без рубрики. Bookmark the permalink.