Binary Tree Zigzag Level Order Traversal

Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, then right to left for the next level and alternate between). For example:Given binary tree [3,9,20,null,null,15,7], 3 / \ 9 20 / \ 15 7 return its zigzag level order traversal as: [ [3], [20,9], [15,7] ] Solution Level …

Continue reading Binary Tree Zigzag Level Order Traversal

Binary Tree Paths

Given a binary tree, return all root-to-leaf paths. Note: A leaf is a node with no children. Example: Input: 1 / \ 2 3 \ 5 Output: ["1->2->5", "1->3"] Explanation: All root-to-leaf paths are: 1->2->5, 1->3 DFS Straight Forward Approach /** * Definition for a binary tree node. * public class TreeNode { * public int …

Continue reading Binary Tree Paths

Group Anagrams

Given an array of strings, group anagrams together. Example: Input: ["eat", "tea", "tan", "ate", "nat", "bat"], Output: [ ["ate","eat","tea"], ["nat","tan"], ["bat"] ] Note: All inputs will be in lowercase.The order of your output does not matter. Leetcode 6th day challenge C# Program Solution - Easy to Understand public class Solution { public IList<IList<string>> GroupAnagrams(string[] strs) { …

Continue reading Group Anagrams

Reverse Substrings Between Each Pair of Parentheses

Introduction Hi friends! Welcome to 100 Days of Leetcode Challenge. In this article, we going to see about Reverse Substrings Between Each Pair of Parentheses. Language I took C# programming language to solve this problem. Since language is independent of the problem. You can use whatever language you wish to solve. Only problem solving approach(logic) …

Continue reading Reverse Substrings Between Each Pair of Parentheses

Alphabet Board Path

INTRODUCTION In this article, we will see about Alphabet Board Path. It is one of the interesting problem, find Alphabet Board Path. BACKGROUND Day 14 of 100 Days of Leetcode Programming Challenge. This is one of the top Leetcode Problem. This problem tests our logical skills. LANGUAGE I took C# programming language to solve this …

Continue reading Alphabet Board Path

How to Reorganize String?

INTRODUCTION In this article, we will see about How to Reorganize String? It is one of the interesting problem, Reorganizing string. Background Day 13 of 100 Days of Leetcode Programming Challenge. This is one of the top Leetcode Problem. This problem tests our knowledge in string manipulations and hashing. Related Problems Top K Frequent ElementsHow …

Continue reading How to Reorganize String?

How to Sort Characters By Frequency?

Introduction In this article, we will see about How to sort characters based upon frequency? Background Day 12 of 100 Days of Leetcode Programming Challenge. This is one of the top Leetcode Problem. This problem tests our knowledge in Map data structure and Sorting. Language I took C# programming language to solve this problem. Since …

Continue reading How to Sort Characters By Frequency?

Evaluate Reverse Polish Notation

Hi Geeks! Welcome to 100 Days of Leetcode Challenge. Day 4 Evaluate the value of an arithmetic expression in Reverse Polish Notation. Valid operators are +, -, *, /. Each operand may be an integer or another expression. Note: Division between two integers should truncate toward zero.The given RPN expression is always valid. That means the expression would always evaluate …

Continue reading Evaluate Reverse Polish Notation

Difference between string and String in C#

In this article, we will learn about what is the difference between string and String in C#. In C#, string is an alias for the String class in .NET. In fact, every C# type has an equivalent in .NET. As another example, short and int in C# map to Int16 and Int32  in .NET. In C#, string is a class. Both string and String class comes from …

Continue reading Difference between string and String in C#

C# Program to Validate IP Address

Hi geeks, in this article we going to see about the Leetcode's Validate Ip Address Problem. This is one of the important interview question. There are different ways to solve this problem like Naive Approach, Straight Forward Approach, etc. But I solved this problem in a efficient way by using Microsoft framework's packages like System.Net, …

Continue reading C# Program to Validate IP Address

ZigZag Conversion

The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility) P A H N A P L S I I G Y I R And then read line by line: "PAHNAPLSIIGYIR" Write the code that will take …

Continue reading ZigZag Conversion

C# Program to Reverse Integer

Given a 32-bit signed integer, reverse digits of an integer. Example 1: Input: 123 Output: 321 Note:Assume we are dealing with an environment which could only store integers within the 32-bit signed integer range: [−231,  231 − 1]. For the purpose of this problem, assume that your function returns 0 when the reversed integer overflows. Required …

Continue reading C# Program to Reverse Integer

The Complete C# tutorials

Get ready folks! The Complete C# tutorials is coming very soon with high quality content and detailed explanations! What is C#? History of C# Java vs C# Environment Setup C# Program Structure C# Variables and Data types C# Value and Reference Types C# Control Statements C# Keywords C# Functions C# Arrays C# Class and Objects …

Continue reading The Complete C# tutorials

Constructors in C#

This article explains about Constructors, types of Constructors and why we need Constructors in a class. Every class requires a constructor to create a instance of that class. It is a special method present in the class. To initialize the variables of the class, we need Constructor. The name of the constructor should be same …

Continue reading Constructors in C#

Reverse string in C#

Hi Geeks! This is a little pretty interesting question. How to reverse the string in C#? There are different ways available in C# to reverse the string. In this article, I'm going to discuss with you. Come on, Let's examine that different ways. Input: "Developers Inspired" Output: "deripnsI srepoleveD" Our input and output is above😍 …

Continue reading Reverse string in C#