starshinata
starshinata
CC#
Created by starshinata on 12/12/2023 in #help
Certificate authentication only for certain paths - ASP.NET
Hi all, does anyone know how I can set up ASP to do certificate authentication only on certain paths? I need to have one method that requires certificate, and another that is unauthenticated. MSDN says there is no way to do it (https://learn.microsoft.com/en-us/aspnet/core/security/authentication/certauth?view=aspnetcore-8.0#can-i-configure-my-app-to-require-a-certificate-only-on-certain-paths)
1 replies
CC#
Created by starshinata on 11/11/2023 in #help
Can't understand why this solution for a HackerRank problem is not working
Here is the link to the problem: https://www.hackerrank.com/challenges/count-triplets-1/problem?isFullScreen=true&h_l=interview&playlist_slugs%5B%5D=interview-preparation-kit&playlist_slugs%5B%5D=dictionaries-hashmaps Here is my solution: (fails for test cases 6 and 10)
private static long GetNumberOfTriplets(long[] array, long ratio)
{
var frequencyByInteger = array
.GroupBy(item => item)
.ToDictionary(g => g.Key, g => g.LongCount());

if (ratio == 1) return frequencyByInteger.Values.Sum(v => v * (v - 1) * (v - 2) / 6);

return array.Distinct()
.Where(v => frequencyByInteger.ContainsKey(v * ratio)
&& frequencyByInteger.ContainsKey(v * ratio * ratio))
.Sum(v => frequencyByInteger[v] * frequencyByInteger[v * ratio] * frequencyByInteger[v * ratio * ratio]);
}
private static long GetNumberOfTriplets(long[] array, long ratio)
{
var frequencyByInteger = array
.GroupBy(item => item)
.ToDictionary(g => g.Key, g => g.LongCount());

if (ratio == 1) return frequencyByInteger.Values.Sum(v => v * (v - 1) * (v - 2) / 6);

return array.Distinct()
.Where(v => frequencyByInteger.ContainsKey(v * ratio)
&& frequencyByInteger.ContainsKey(v * ratio * ratio))
.Sum(v => frequencyByInteger[v] * frequencyByInteger[v * ratio] * frequencyByInteger[v * ratio * ratio]);
}
I know there are a lot of solutions to this online, but I want to specifically understand why the above solution is not correct. My current assumption is that I've found something nobody else before me has found and it's a HackerRank bug, meaning my code is correct. Would be happy to be proven wrong.
4 replies