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
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; | |
} |
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 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; | |
} |
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
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]; | |
} |