public class Solution {
public string DefangIPaddr(string address) {
return address.Replace(".", "[.]");
}
}
Source:
https://leetcode.com/problems/defanging-an-ip-address/
"Simplicity can't be bought later, it must be earned from the start" -- DB
Sunday, February 14, 2021
Leetcode Everyday: 1108. Defanging an IP Address. Easy
Leetcode Everyday: 1480. Running Sum of 1d Array. Easy
public class Solution {
public int[] RunningSum(int[] nums) {
var accum = 0;
var list = new List<int>();
foreach (var n in nums) {
accum += n;
list.Add(accum);
}
return list.ToArray();
}
}
Source:
https://leetcode.com/problems/running-sum-of-1d-array/
Monday, August 17, 2020
Rotating numbers for base 2
using System;
public class Program
{
public static void Main()
{
ShowCircle(32);
ShowCircle(512);
}
static void ShowCircle(int n) {
int masker = n - 1;
for (int i = -(n * 2); i <= n * 2; ++i) {
Console.WriteLine("{0,6}: {1,6} {2,6} {3,6}", n, i, i & masker, (i % n + n) % n);
}
}
}
https://dotnetfiddle.net/DedpF2
Friday, March 13, 2020
Parameter Sniffing
Parameter sniffing with repro steps:
https://www.red-gate.com/simple-talk/sql/t-sql-programming/parameter-sniffing/
Other good articles explaining parameter sniffing:
https://www.brentozar.com/archive/2013/06/the-elephant-and-the-mouse-or-parameter-sniffing-in-sql-server/
https://hackernoon.com/why-parameter-sniffing-hurts-your-sql-query-performance-d73c0da71fbc
I encountered that problem some time in 2014, if I remember correctly I was able to solve that problem using this:
Basically, it prevents SQL Server from sniffing the parameter since it can't identify the parameter values used in the SELECT statement as the WHERE clause is not directly using the parameter variable that passed to it, thereby making SQL Server create a different execution plan every time the stored procedure is executed instead of reusing old execution plan that could otherwise be non-optimal for a given set of parameter values.
https://www.red-gate.com/simple-talk/sql/t-sql-programming/parameter-sniffing/
Other good articles explaining parameter sniffing:
https://www.brentozar.com/archive/2013/06/the-elephant-and-the-mouse-or-parameter-sniffing-in-sql-server/
https://hackernoon.com/why-parameter-sniffing-hurts-your-sql-query-performance-d73c0da71fbc
I encountered that problem some time in 2014, if I remember correctly I was able to solve that problem using this:
DROP PROC [dbo].[DisplayBillingInfo] GO CREATE PROC [dbo].[DisplayBillingInfo] @BeginDate DATETIME, @EndDate DATETIME WITH RECOMPILE AS DECLARE @StartDate DATETIME; DECLARE @StopDate DATETIME; SET @StartDate = @BeginDate; SET @StopDate = @EndDate; SELECT BillingDate, BillingAmt FROM BillingInfo WHERE BillingDate between @StartDate AND @StopDate;
Basically, it prevents SQL Server from sniffing the parameter since it can't identify the parameter values used in the SELECT statement as the WHERE clause is not directly using the parameter variable that passed to it, thereby making SQL Server create a different execution plan every time the stored procedure is executed instead of reusing old execution plan that could otherwise be non-optimal for a given set of parameter values.
Wednesday, October 23, 2019
Cannot GET /
I get that error when I create project on a junction directory
This junction directory:
C:\User\Developer\Codes
points to:
D:\dev-codes
To avoid the error, just create the project directly on D:\dev-codes
I want to emulate Unix/Linux's symlink in Windows by using junction directory, so the directory appears local to current user, and also to prevent the internal SSD from wearing out quickly. However, for some reasons, Visual Studio is having problems compiling from a junction directory.
This junction directory:
C:\User\Developer\Codes
points to:
D:\dev-codes
To avoid the error, just create the project directly on D:\dev-codes
I want to emulate Unix/Linux's symlink in Windows by using junction directory, so the directory appears local to current user, and also to prevent the internal SSD from wearing out quickly. However, for some reasons, Visual Studio is having problems compiling from a junction directory.
Subscribe to:
Posts (Atom)