This file contains 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
public static string reverseString(string str) | |
{ | |
return !string.IsNullOrEmpty(str) ? reverse(str) : string.Empty; | |
} | |
private static string reverse(string str) | |
{ | |
var stk = new Stack(); | |
for (int i = 0; i < str.Length; i++) | |
{ |
This file contains 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
// input: Welcome to Csharp corner | |
// output: corner Csharp to Welcome | |
internal static void ReverseWordOrder(string str) | |
{ | |
int i; | |
StringBuilder reverseSentence = new StringBuilder(); | |
int Start = str.Length - 1; | |
int End = str.Length - 1; |
This file contains 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
public class ParenthesisBalancing | |
{ | |
public bool checkIfParanthesisIsBalanced(string str) | |
{ | |
return !string.IsNullOrEmpty(str) ? check(str) : false; | |
} | |
private bool check(string str) | |
{ | |
var s = new Stack(); |
This file contains 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
internal string isPalindrome(string str) | |
{ | |
bool flag = false; | |
if (!string.IsNullOrEmpty(str)) | |
{ | |
for (int i = 0, j = str.Length -1; i < str.Length /2; i++, j--) | |
{ | |
if (str[i] != str[j]) | |
{ | |
flag = false; |
This file contains 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
// Stack Implementation | |
const char leftParenthesis = '('; | |
const char rightParenthesis = ')'; | |
const string inputStr = "((())())()()"; | |
public bool checkIfBalanced(){ | |
var items = new Stack<int>(inputStr.Length); | |
for(int i = 0; i < inputStr.Length; i++){ |
This file contains 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
// C# implementation with node traversing | |
public static int[] arr = {9, 1, 9, 0, 7, 0, 3, 5, 0}; | |
public int[] pushZerosToEnd(){ | |
var arrCount = arr.Count(); | |
var count = 0; | |
for (int i = 0; i < arrCount; i++){ | |
if (arr[i] != 0){ | |
arr[count++] = arr[i]; | |
} |
This file contains 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
public int GetDescendantsCount(Item item) | |
{ | |
using (SqlConnection conn = new SqlConnection(Sitecore.Configuration.Settings.GetConnectionString(Sitecore.Context.Database.ConnectionStringName))) | |
{ | |
try | |
{ | |
conn.Open(); | |
Assert.IsNotNull(item, "A valid Sitecore item must be provided to this method"); | |
string query = @"with cteChildren as |
This file contains 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
{ | |
"Version":"2008-10-17", | |
"Statement":[{ | |
"Sid":"AllowPublicRead", | |
"Effect":"Allow", | |
"Principal": { | |
"AWS": "*" | |
}, | |
"Action":["s3:GetObject"], | |
"Resource":["arn:aws:s3:::bucket/*" |
This file contains 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
<?php | |
/* | |
Controller name: Layouts & Components | |
Controller description: Custom layouts and components controller | |
*/ | |
class JSON_API_Custom_JSON_API_Controller { | |
// Get all components | |
public function get_components() { |
This file contains 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
/* | |
Place this code within functions.php file. | |
(Or) to your plugins folder if you are building a custom plugin | |
*/ | |
function cc_mime_types( $mimes ){ | |
$mimes['svg'] = 'image/svg+xml'; | |
return $mimes; | |
} | |
add_filter( 'upload_mimes', 'cc_mime_types' ); |
NewerOlder