Wednesday, September 20, 2023

底特律福特F-150工厂游

 博物馆有专车接送到工厂参观,距离大约十几分钟车程。工厂游分成五部分,一些项目不能摄像,有关的图像资料是从网上找到的。参观第一站,是看回顾福特公司历史的影片,十多分钟的时间,对创始人福特,第一辆汽车和流水线的发明都会有进一步了解。第二站,相当酷,是4D影院,声光电结合,介绍F-150的生产。第三站,到工厂的观景台,有人介绍工厂情况,从这里可以看到厂区和绿色的环保屋顶。第四站,是进入车间,游客沿着二楼设计的路线,可以看到下面车间的组装线,因为我们是周日去的,所以没有工人上班,否则这里每周六天24小时都有工人工作,好在网上视频资料可以脑补。最后一站的大厅里,展示了福特公司的经典车型和拆解的F-150皮卡。整个参观需要2小时时间。 

龚明鹏牧师

 

龚明鹏牧师

龚明鹏牧师

生于中国福建,出国前在北京中国科学院从事数学研究工作。94年到加拿大留学,98年获滑铁泸(Waterloo)大学数学博士学位。于96年重生得救。博士毕业后便回到大陆农村传福音。2001-2020期间在多伦多华夏圣经教会牧会,并担任教会主任牧师。自2021年起,继续在多伦多华夏圣经教会西堂牧会,同时担任Vision Ministries Canada华人教会联会(CCA-VMC)总干事。生命季刊加拿大分部董事。

题目:住在至高者的隐秘处

经文:诗篇91

简介:面对疫情、战争,外在环境的艰难,也包括教会中各样乱象,诗篇91篇把我们带回信仰的根基,回到神自己的身上。当我们学会住在至高者的隐秘处时,就得以住在全能者的荫下。愿神安定在天、历久弥香的话语,成为我们在这个世代行天路随时的帮助。

Life Makeover: Embrace the Bold, Beautiful, and Blessed You

Have you ever been so overwhelmed by responsibilities or other people's needs that you forgot to make time for yourself? They say beauty is only skin-deep, but there is power in embracing your outward beauty as the first step in living with internal boldness, confidence, and renewed joy.

An outside-in approach to beauty isn't for other people's perception of you, but for your interpretation of yourself and how much you're willing to explore. Sachse has confirmed the unmistakable link between external appearance and self-confidence, and she wants to show you how to rekindle both.

In the pages of this book, Sachse offers a vulnerable look into her own mistakes and imperfections and explains how making over her outward appearance resulted in a happier and healthier version of herself--emotionally, spiritually, and physically.

Filled with confidence-boosting wisdom about cultivating rest and lifegiving hobbies, Sachse shows you:

  • how making small changes to your outward appearance can be a pathway to building confidence and making other new transformations in your life
  • practical tips about hair, makeup, and fashion from an expert
  • the benefits of taking bold risks - your life is too valuable to be left on autopilot
  • how to analyze your past and see where you self-sabotaged, and look for traits that served you well and can serve you in the future

Sachse knows no amount of makeup can compare to the look of a confident, classy, and kind woman, and that there's nothing like the glow that comes from inner beauty. It's time to discover--or rediscover--who you really are and live your life to the fullest.

14 Things I Learned From Cycling Camino de Santiago

Here is the link.

Leetcode.com | Dhairya Dhondiyal | Top voted algorithms

 


Here is the link. 

https://leetcode.com/PhoenixDD/

Monday, September 18, 2023

Leetcode.com | 536 Construct binary tree from string | C# solution

Here is my discuss post. 

C# | Recursive function | It is challenging

Sept. 18, 2023

Intuition

It takes time for me to warm up recursive function. I learn how to write a working recursive function to parse the string into a binary tree.

Approach

The following are highlights of successful recursive solution:

  1. Tried to solve it by myself first 20 minutes;
  2. Studied Leetcode premimum solution called Editorial provided by Leetcode;
  3. Studied recursive solution;
  4. Wrote a C# solution as well; Spend time to debug
  5. Cases in recursive function: left child, right child, and close ')'

Complexity

  • Time complexity:

O(N), N is the length of string

  • Space complexity:

Code

/**
 * Definition for a binary tree node.
 * public class TreeNode {
 *     public int val;
 *     public TreeNode left;
 *     public TreeNode right;
 *     public TreeNode(int val=0, TreeNode left=null, TreeNode right=null) {
 *         this.val = val;
 *         this.left = left;
 *         this.right = right;
 *     }
 * }
 */
public class Solution {
    /// <summary>
        /// 536 Construct binary tree from string 
        /// </summary>
        /// <param name="s"></param>
        /// <returns></returns>
        public TreeNode Str2tree(string s)
        {
            return str2treeInternal(s, 0).Item1; 
        }

        /// <summary>
        /// Parse an integer starting from given position - index 
        /// </summary>
        /// <param name="s"></param>
        /// <param name="index"></param>
        /// <returns></returns>
        private Tuple<int, int> getNumber(String s, int index)
        {
            var isNegative = false;

            // A negative number
            if (s[index] == '-')
            {
                isNegative = true;
                index++;
            }

            int number = 0;
            // Use Char.IsDigit to save time
            while (index < s.Length && Char.IsDigit(s[index]))
            {
                number = number * 10 + (s[index] - '0');
                index++;
            }

            return new Tuple<int, int>(isNegative ? -number : number, index);
        }

        /// <summary>
        /// Work on recursive function - basics of recursive function design 
        /// </summary>
        /// <param name="s"></param>
        /// <param name="index"></param>
        /// <returns></returns>
        private Tuple<TreeNode, int> str2treeInternal(string s, int index)
        {
            if (index == s.Length)
            {
                return new Tuple<TreeNode, int>(null, index);
            }

            // Start of the tree will always contain a number representing
            // the root of the tree. So we calculate that first.
            var tuple = getNumber(s, index);

            int value = tuple.Item1;
            index = tuple.Item2;

            var node = new TreeNode(value);                      

            // Next, if there is any data left, we check for the first subtree
            // which according to the problem statement will always be the left child.
            if (index < s.Length && s[index] == '(')
            {
                var data = this.str2treeInternal(s, index + 1);

                node.left = data.Item1;
                index = data.Item2;
            }

            // Indicates a right child
            if (node.left != null && index < s.Length && s[index] == '(')
            {
                var data = this.str2treeInternal(s, index + 1);

                node.right = data.Item1;
                index = data.Item2;
            }

            // 
            return new Tuple<TreeNode, int>(node, index < s.Length && s[index] == ')' ? index + 1 : index);
        }
}