- Converted
List<T>
toarray
after reading this - Changed
foreach
to a plainfor
loop that helped remove another index variable for iterating over stringt
- Converted
List<T>
toarray
after reading this - Changed
foreach
to a plainfor
loop that helped remove another index variable for iterating over stringt
I solved this problem.:
For example,:
The code in C# on average took around 109ms to execute, which is a pretty slow as compared C++
to the C++ version of the same algorithm than, which executes in under 6ms. Although, the fastest C#
solutionC# solution for this problem is around 100ms.
Optimization?Optimizations I had done:
- Converted
List<T>
toarray
after reading this - Changed
foreach
to a plainfor loop
loop that helped remove another index variable for iterating over stringt
Can you suggest if there is any better way to squeeze some performance from the C#
C# implementation.?
And from the FAQ section of LeetCode I could see that C#
C# uses mono 4.2.1
mono 4.2.1 and C++
C++ uses g++ 5.4.0
g++ 5.4.0.
I'm attaching the C++
C++ solution as well just for reference:
I solved this problem.
For example,
The code in C# on average took around 109ms to execute which is a pretty slow as compared C++
version of the same algorithm than executes in under 6ms. Although the fastest C#
solution for this problem is around 100ms
Optimization? I had done
- Converted
List<T>
toarray
after reading this - Changed
foreach
to plainfor loop
that helped remove another index variable for iterating over stringt
Can you suggest if there is any better way to squeeze some performance from the C#
implementation.
And from the FAQ section of LeetCode I could see that C#
uses mono 4.2.1
and C++
uses g++ 5.4.0
I'm attaching the C++
solution as well just for reference
I solved this problem:
For example:
The code in C# on average took around 109ms to execute, which is pretty slow compared to the C++ version of the same algorithm, which executes in under 6ms. Although, the fastest C# solution for this problem is around 100ms.
Optimizations I had done:
- Converted
List<T>
toarray
after reading this - Changed
foreach
to a plainfor
loop that helped remove another index variable for iterating over stringt
Can you suggest any better way to squeeze some performance from the C# implementation?
And from the FAQ section of LeetCode I could see that C# uses mono 4.2.1 and C++ uses g++ 5.4.0.
I'm attaching the C++ solution as well just for reference: