Skip to content

Instantly share code, notes, and snippets.

@edward-hsu-1994
Last active June 11, 2019 13:21
Show Gist options
  • Save edward-hsu-1994/ad5d1a91a5911545371f8fb332c76fee to your computer and use it in GitHub Desktop.
Save edward-hsu-1994/ad5d1a91a5911545371f8fb332c76fee to your computer and use it in GitHub Desktop.
public static string Test2(string str) {
if (str.Length == 0) return str;
return str[str.Length - 1] + Test2(str.Substring(0, str.Length - 1));
}
public static string Test3(string str) {
if (str.Length < 4) return str;
return Test3(str.Substring(0, str.Length - 3)) + "," + str.Substring(str.Length - 3);
}
public static int? Test4(int[] vals, int index = 0, int? result = null) {
if (vals.Length == 0 || index == vals.Length) return result;
return Test4(vals, index + 1, result > vals[index] ? result.Value : vals[index]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment