前言
甚麼是創建者模式,將一個複雜對象的構建與他的表示分離,使得同樣的構建過程可以創建不同的表示。 一步一步創建一個複雜的對象,它允許用戶只通過指定複雜對象的類型和內容就可以建構它們,用戶不需要知道內部的具體建構細節。
建造者模式客戶端返回的不是一個簡單的產品,而是一個由多個部件組成的複雜產品。
Difficult:Medium
An n-bit gray code sequence is a sequence of 2n integers where:
Every integer is in the inclusive range [0, 2n - 1],
The first integer is 0,
An integer appears no more than once in the sequence,
The binary representation of every pair of adjacent integers differs by exactly one bit, and
The binary representation of the first and last integers differs by exactly one bit.
Given an integer n, return any valid n-bit gray code sequence.
Difficult:Easy
You are given two integer arrays nums1 and nums2, sorted in non-decreasing order, and two integers m and n, representing the number of elements in nums1 and nums2 respectively.
Merge nums1 and nums2 into a single array sorted in non-decreasing order.
The final sorted array should not be returned by the function, but instead be stored inside the array nums1. To accommodate this, nums1 has a length of m + n, where the first m elements denote the elements that should be merged, and the last n elements are set to 0 and should be ignored. nums2 has a length of n.