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?

Squares of a Sorted Array

Day 8 Welcome to 100 Days of Leetcode Challenge. Given an array of integers A sorted in non-decreasing order, return an array of the squares of each number, also in sorted non-decreasing order. Example 1: Input: [-4,-1,0,3,10] Output: [0,1,9,16,100] Example 2: Input: [-7,-3,2,3,11] Output: [4,9,9,49,121] Note: 1 <= A.length <= 10000-10000 <= A[i] <= 10000A is sorted in non-decreasing order. … Continue reading Squares of a Sorted Array

100 Days Leetcode Challenge

Hi Geeks! Welcome to 100 Days Leetcode challenge. In these days, we going to solve Leetcode's top 100 data structures and algorithm problems. Purpose of 100 Days Leetcode Challenge The main purpose of this challenge is, as a Software Developer we should have a strong command over the algorithms and data structures.Solving these problems daily, … Continue reading 100 Days Leetcode Challenge

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: InsertDeleteSearch TrieNode class TrieNode { int terminating; TrieNode[] trieNodes = new TrieNode[26]; public TrieNode next(final char c) { return trieNodes[c - 'a']; } } … Continue reading Trie data structure

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

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 … Continue reading Valid Number

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

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 arra < bb - a equals to the minimum absolute difference of any two elements in arr Example 1: Input: arr = [4,2,1,3] Output: [[1,2],[2,3],[3,4]] … Continue reading Minimum Absolute Difference