LeetCodeのLongest Substring Without Repeating Charactersにて
Sliding Windowアルゴリズムを実装している例を写経している時に
int[] chars = new int[26];
という表現を見つけたので何故このような宣言をしているかを調べた。
結果としては単純にアルファベットの数分の領域を確保するために行なっているよう。
他にも
int[] chars = new int[128];
や、
int[] chars = new int[256];
が存在するが、これらはint[128]
は ASCII用、int[256]
は拡張 ASCII用ということだった。
ASCIIは7ビット、拡張ASCIIは8ビットを使用していることを考えれば容易に思いつくはずなのに、調べないと分からなかったので記事にしました。
多分また調べるんだろうなぁ…
We can customise each report - freed from charge - including purchasing stand-alone sections or country-level stories, nicely as|in addition to} offer affordable reductions for start-ups & 우리계열 universities. Ou'll be rewarded with your free $10 sign-up bonus immediately after registration. From there, you may have to wager 1x to make the "free cash" winnings withdrawable.
返信削除