Skip to content

Instantly share code, notes, and snippets.

View letscodego's full-sized avatar
🌱

K1 letscodego

🌱
View GitHub Profile
@letscodego
letscodego / WindowsTerminal.md
Created September 26, 2022 07:23 — forked from dahlsailrunner/WindowsTerminal.md
Customization and Setup notes for Windows Terminal
@letscodego
letscodego / gist:341166e0124e9ea1f21705dc12375f6a
Created August 20, 2022 07:00
Update the author and email address of every commit on a repository
git filter-branch --env-filter '
OLD_EMAIL="old@email"
CORRECT_NAME="newName"
CORRECT_EMAIL="new@email"
if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ]
then
export GIT_COMMITTER_NAME="$CORRECT_NAME"
export GIT_COMMITTER_EMAIL="$CORRECT_EMAIL"
fi
if [ "$GIT_AUTHOR_EMAIL" = "$OLD_EMAIL" ]
client.ClientCredentials.Windows.ClientCredential.Domain = "WorkstationName";
client.ClientCredentials.Windows.ClientCredential.UserName = "blabla";
client.ClientCredentials.Windows.ClientCredential.Password = "blabla123";
public static bool IsAnagram(string s, string t)
{
if (s.Length != t.Length)
return false;
var s_hash = new Hashtable();
var t_hash = new Hashtable();
for (var i = 0; i < s.Length; i++)
{
s_hash[s.Substring(i, 1)] = 1 +
(int)(s_hash.ContainsKey(s.Substring(i, 1)) ?
public static int[] TwoSum(int[] nums, int target)
{
if (nums.Length < 2)
return new int[2];
var dic = new Dictionary();
for (var i = 0; i < nums.Length; i++)
{
if (dic.ContainsKey(target - nums[i]))
{
public static int[] TopKFrequent(int[] nums, int k)
{
if (nums.Length == 0 || k == 0)
return Array.Empty<int>();
var result = new List<int>();
Dictionary<int, int> dic = new Dictionary<int, int>();
foreach (var item in nums)
{
if (dic.ContainsKey(item))
@letscodego
letscodego / TopKFrequent.cs
Created August 13, 2022 06:38
TopKFrequent
public static int[] TopKFrequent(int[] nums, int k)
{
//By bucket sort
if (nums.Length == 0 || k == 0)
return Array.Empty();
var result = new List();
Dictionary num2count = new Dictionary();
foreach (var item in nums)
{
@letscodego
letscodego / LongestConsecutive.cs
Last active August 13, 2022 07:04
Longest Consecutive
public static int LongestConsecutive(int[] nums)
{
var hashset = new HashSet(nums);
var longest = 1;
foreach (var item in nums)
{
if (hashset.Contains(item - 1))
continue;
if (hashset.Contains(item + 1))
{