This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /// <summary> | |
| /// Find Missing Number | |
| /// <param name="nums">input num int array</param> | |
| /// <returns></returns> | |
| private static int FindMissingNumber(int[] nums) | |
| { | |
| int result = 0; | |
| int i = 0; | |
| for (i = 0; i < nums.Length; i++) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private static int GetSingleNumberByDictionary(int[] nums) | |
| { | |
| Dictionary<int, int> dic = new Dictionary<int, int>(); | |
| int value = 0; | |
| foreach (int num in nums) | |
| { | |
| if (dic.TryGetValue(num, out value)) | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private static int GetSingleNumberByHashSet(int[] nums) | |
| { | |
| HashSet<int> numList = new HashSet<int>(); | |
| foreach (int num in nums) | |
| { | |
| if (numList.Contains(num)) | |
| { | |
| numList.Remove(num); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private static int GetSingleNumber(int[] nums) | |
| { | |
| int singleNumber = 0; | |
| foreach (var num in nums) | |
| { | |
| singleNumber = singleNumber ^ num; | |
| } | |
| return singleNumber; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class Person | |
| { | |
| /// <summary> | |
| /// 男:M , 女:F | |
| /// </summary> | |
| public char gender { get; set; } | |
| /// <summary> | |
| /// 年齡 | |
| /// </summary> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| static int BinarySearch(int[] inputArray,int target) | |
| { | |
| int low = 0; | |
| int high = inputArray.Length - 1; | |
| while (high >= low) | |
| { | |
| int middle = (low + high) / 2; | |
| if (inputArray[middle] == target) | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static void sayHelloKitty(int number) | |
| { | |
| for (int i = 0; i < number; i++) | |
| { | |
| Console.WriteLine($"Hello Kitty {number}"); | |
| } | |
| for (int j = 0; j < number; j++) | |
| { | |
| Console.WriteLine($"Hello Kitty {number}"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static void sayHelloKitty(int number) | |
| { | |
| for (int i = 0; i < number; i++) | |
| { | |
| for (int j = 0; j < number; j++) | |
| { | |
| Console.WriteLine($"Hello Kitty {number}"); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static void sayHelloKitty(int number) | |
| { | |
| for (int i = 0; i < number; i++) | |
| { | |
| Console.WriteLine($"Hello Kitty {number}"); | |
| } | |
| return; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static void helloKitty(int number) | |
| { | |
| for (int i = 0; i < 10; i++) | |
| { | |
| Console.WriteLine($"Hello Kitty {i}"); | |
| } | |
| return; | |
| } |
NewerOlder