發表文章

LeetCode: Populating Next Right Pointers in Each Node

圖片
  You are given a   perfect binary tree  where all leaves are on the same level, and every parent has two children. The binary tree has the following definition: struct Node { int val; Node *left; Node *right; Node *next; } Populate each next pointer to point to its next right node. If there is no next right node, the next pointer should be set to  NULL . Initially, all next pointers are set to  NULL .   Follow up: You may only use constant extra space. Recursive approach is fine, you may assume implicit stack space does not count as extra space for this problem.   Example 1: Input: root = [1,2,3,4,5,6,7] Output: [1,#,2,3,#,4,5,6,7,#] Explanation: Given the above perfect binary tree (Figure A), your function should populate each next pointer to point to its next right node, just like in Figure B. The serialized output is in level order as connected by the next pointers, with '#' signifying the end of each level.   Constraints: The number of nodes in the given tree is

UE4 TUTORIAL : BLUEPRINTS 筆記

圖片
同步發: https://travisnotathome.blogspot.com/2020/06/ue4-tutorial-blueprints.html 先說目前心得結論。 Blueprint : Unreal提供的類Unity Prefab製作方式。而此prefab的程式component可以用類似拉線路圖拼圖的方式來組合程式互動邏輯。 ------------------------------------------ 參考教學 :  https://www.raywenderlich.com/663-unreal-engine-4-blueprints-tutorial 建立Blueprints (class)時,他會請你選擇要繼承時做的class類別 大致看下來: Actor : 所有可以被丟到world裡的都叫Actor (即便他可能是不能幹嘛的花瓶)。 Pawn :  繼承自Actor,可以被user操作和接受user input的Actor。 Character : 繼承自Pawn,自帶四處走的功能了。 Player Controller : (目前還沒用到先不講) Game Mode Base :  決定一些遊戲機制的物件 ,ex:玩家生成位置、輸入操作系統、如何進入遊戲、計分? 完成Game Mode Base設計之後, 要記得到Setting/World Setting告訴這個world你採用哪個Game Mode Base。 (其他還沒用到過所以不太清楚) 總之先設定好Game Mode Base後,同時也要設定 要產生的玩家可操作物件(Default Pawn Class) 為何。 在Scene(Unreal中稱 Level)中放入Player Strat物件,該物件會決定player一開始生成出現的位置。 設定Input 要在unreal中做輸入與互動操作並在blueprint中編輯的話,需要先到Edit\Project setting\Input中設定 在這裡建立 綁定Binding 你的輸入key資訊 :  Unreal提供兩種key binding Action Mapping : 該key只能存在兩種狀況 : "按下去"與"沒按下去"。也就是非0即1。 Axis Mapping : 有程度