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
/* | |
Given a string s, return the longest palindromic substring in s. | |
Example 1: | |
Input: s = "babad" | |
Output: "bab" | |
Explanation: "aba" is also a valid answer. | |
Example 2: | |
Input: s = "cbbd" | |
Output: "bb" | |
*/ |
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
/* | |
Input : [“hello”, “world”, “message”] | |
Separator: “ +++ ” | |
Result: “hello +++ world +++ message” | |
*/ | |
using System; | |
using System.Collections.Generic; | |
var input = new List<string>{"hello","world","message"}; |
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
/* | |
check wellformedbracing | |
Input Result Comment | |
“(( ))” True | |
“( )( )” True | |
“(( )))((( ))” False Although it has the same amount of opening and closing braces, | |
it is not properly nested | |
“((( )” False No suitable bracing |
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
//Version 1 Version 2 Result | |
//1.11.17 2.3.5 2.3.5 | |
//2.1 2.1.3 2.1.3 | |
//2.3.5 2.4 2.4.0 | |
//3.1 2.4 3.1.0 | |
//3.3 3.2.9 3.3.0 | |
//7.2.71 7.2.71 7.2.71 | |
string s1 = "2.1"; |
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
//even before odd numbers | |
//Input Result | |
//[1, 2, 3, 4, 5, 6, 7, 8, 9, 10] [2, 4, 6, 8, 10, 3, 7, 1, 9, 5] | |
//[2, 4, 6, 1, 8] [2, 4, 6, 8, 1] | |
//[2, 4, 6, 8, 1] [2, 4, 6, 8, 1] | |
var lst = new List<int> { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; | |
var lstEven = new List<int>(); | |
var lstOdd = new List<int>(); |
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
//Palindrome Lists | |
//Input Result | |
//[“One”, “Test”, “ – ”, “Test”, “One”] True | |
//[“Max”, “Mike”, “Mike”, “Max”] True | |
//[“Tim”, “Tom”, “Mike”, “Max”] False | |
//var lst = new List<string>() { "One", "Test", "–", "Test", "One" }; | |
var lst = new List<string>() { "Max", "Mike", "Mike", "Max"}; | |
var cnt = lst.Count()/2; |
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
//Add One to an Array as a Number | |
//Input Result | |
//[1, 3, 2, 4] [1, 3, 2, 5] | |
//[1, 4, 8, 9] [1, 4, 9, 0] | |
//[9, 9, 9, 9] [1, 0, 0, 0, 0] | |
var lst = new List<int> { 1, 4, 8, 9 }; | |
var one = 1; | |
var revlst = lst.ToArray().Reverse().ToList(); |
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
//Desc: Array Split | |
//Say you have an array (or list) of arbitrary integers. | |
//The data structure must be reordered so that all values less than a | |
//special reference value are placed on the left. All values greater than | |
//or equal to the reference value are placed on the right. | |
//The ordering within the subranges is not relevant and may vary. | |
//Input Reference element Sample result | |
//[4, 7, 1, 20] 9 [1, 4, 7, 9, 20] | |
//[3, 5, 2] 7 [2, 3, 5, 7] |
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
git rev-parse --abbrev-ref HEAD | |
or with Git 2.22 and above: | |
git branch --show-current |
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
Refernce: https://stackoverflow.com/questions/1146973/how-do-i-revert-all-local-changes-in-git-managed-project-to-previous-state | |
#!/bin/sh | |
git reset --hard | |
git clean -f -d | |
git checkout HEAD |
OlderNewer