Skip to content

Instantly share code, notes, and snippets.

View TJayanth's full-sized avatar

Jayanth Thyagarajan TJayanth

View GitHub Profile
@TJayanth
TJayanth / PerfectSquares.cs
Last active October 8, 2016 18:55
Find perfect Squares between two numbers
Perfect squares are numbers like 1,4,9,16,25,......
Given two numbers a and b and to find the perfect squares inbetween these two numbers.
private static int PerfectSquares(int startIndex, int endIndex)
{
int count = (int)Math.Floor(Math.Sqrt(endIndex)) - (int)Math.Ceiling(Math.Sqrt(startIndex)) + 1;
return count;
}
@TJayanth
TJayanth / pangrams.cs
Last active October 8, 2016 18:55
Pangrams - C# solution
Check if the given sentene is pangram or not.
Pangrams are sentences constructed by using every letter of the alphabet at least once
Eg: The quick brown fox jumps over the lazy dog
static bool IsPangram(string s)
{
return s.ToLower().Where(c => Char.IsLetter(c)).GroupBy(c => c).Count() == 26;
}
@TJayanth
TJayanth / LonelyInteger.cs
Last active October 8, 2016 18:53
Lonely Integer - HackerRank
Find an element that is not paired.
Array= {10,5,10,16,17,16,17}
Output: 5
static int lonelyInteger(int[] a) {
int val=0;
for(int i=0;i<a.Length;i++){
val^=a[i];
}