leetcode481】的更多相关文章

A magical string S consists of only '1' and '2' and obeys the following rules: The string S is magical because concatenating the number of contiguous occurrences of characters '1' and '2' generates the string Sitself. The first few elements of string…
public class Solution { public int MagicalString(int n) { ) ; ) ; ]; a[] = ; a[] = ; a[] = ; , tail = , num = , result = ; while (tail < n) { ; i < a[head]; i++) { a[tail] = num; && tail < n) { result++; } tail++; } num = num ^ ;//异或 head…