Data structure

Trie data structure

A trie is a tree like data structure. Trie is also called as prefix tree. In this article, we going to see three main operations of trie data structure. They are: Insert Delete Search TrieNode class TrieNode { int terminating; TrieNode[] trieNodes = new TrieNode[26]; public TrieNode next(final char c) { return trieNodes[c – ‘a’]; …

Trie data structure Read More »

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, …

C# Program to Validate IP Address Read More »

Valid Number

This article explains about Leetcode’s Valid Number Explanation and Solution. Validate if a given string can be interpreted as a decimal number. Some examples:”0″ => true” 0.1 ” => true”abc” => false”1 a” => false”2e10″ => true” -90e3   ” => true” 1e” => false”e3″ => false” 6e-1″ => true” 99e2.5 ” => false”53.5e93″ => true” –6 ” => false”-+3″ => false”95a54e53″ => false Note: It is intended for the problem statement to be ambiguous. You should gather all requirements up front before implementing one. However, here …

Valid Number Read More »

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 …

ZigZag Conversion Read More »

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 …

C# Program to Reverse Integer Read More »

Minimum Absolute Difference

Given an array of distinct integers arr, find all pairs of elements with the minimum absolute difference of any two elements.  Return a list of pairs in ascending order(with respect to pairs), each pair [a, b] follows a, b are from arr a < b b – a equals to the minimum absolute difference of any two elements in arr Example 1: Input: arr = [4,2,1,3] …

Minimum Absolute Difference Read More »