## LeetCode – Sort Characters By Frequency

Given a string, sort it in decreasing order based on the frequency of characters. Example 1: Input: “tree” Output: “eert” Explanation: ‘e’ appears twice while ‘r’ and ‘t’ both appear

Skip to content
## LeetCode – Sort Characters By Frequency

## LeetCode – Count Square Submatrices with All Ones

## LeetCode – Kth Smallest Element in a BST

## LeetCode – Online Stock Span

## LeetCode – Permutation in String

## LeetCode – Find All Anagrams in a String

## LeetCode – Odd Even Linked List

## LeetCode – Maximum Sum Circular Subarray

## LeetCode – Implement Trie (Prefix Tree)

## LeetCode – Remove K Digits

## LeetCode – Single Element in a Sorted Array

## LeetCode – Flood Fill

## LeetCode – Find the Town Judge

## LeetCode – Valid Perfect Square

## LeetCode – Check If It Is a Straight Line

## LeetCode – Cousins in Binary Tree

## LeetCode – Majority Element

## LeetCode – First Unique Character in a String

## LeetCode – Number Complement

## LeetCode – Ransom Note

## LeetCode – Jewels and Stones

## LeetCode – First Bad Version

## LeetCode – Check If a String Is a Valid Sequence from Root to Leaves Path in a Binary Tree – 30Days Challenge

## LeetCode – Binary Tree Maximum Path Sum – 30Days Challenge

## LeetCode – Maximal Square – 30Days Challenge

## LeetCode – Leftmost Column with at Least a One – 30Days Challenge

## LeetCode – Construct Binary Search Tree from Preorder Traversal – 30Days Challenge

## LeetCode – Search in Rotated Sorted Array – 30Days Challenge

## LeetCode – Valid Parenthesis String – 30Days Challenge

## LeetCode – Contiguous Array – 30Days Challenge

## LeetCode – Last Stone Weight – 30Days Challenge

## LeetCode – Bitwise AND of Numbers Range – 30Days Challenge

## LeetCode – First Unique Number – 30Days Challenge

## LeetCode – Backspace String Compare – 30Days Challenge

## LeetCode – Perform String Shifts – 30Days Challenge

## LeetCode – Happy Number – 30Days Challenge

## LeetCode – Best Time to Buy and Sell Stock II – 30Days Challenge

## LeetCode – Product of Array Except Self – 30Days Challenge

## LeetCode – Longest Common Subsequence – 30Days Challenge

## LeetCode – Minimum Path Sum – 30Days Challenge

## LeetCode – Diameter of Binary Tree – 30Days Challenge

## LeetCode – Min Stack – 30Days Challenge

## LeetCode – Middle of the Linked List – 30Days Challenge

## LeetCode – Counting Elements – 30Days Challenge

## LeetCode – Jump Game – 30Days Challenge

## LeetCode – Number of Islands – 30Days Challenge

## LeetCode – Subarray Sum Equals K – 30Days Challenge

## LeetCode – Group Anagrams – 30Days Challenge

## LeetCode – LRU Cache – 30Days Challenge

## LeetCode – Move Zeroes – 30Days Challenge

## LeetCode – Maximum Subarray – 30Days Challenge

## LeetCode – Single Number – 30Days Challenge

## Convert a Binary Tree into its Mirror Tree

## ZigZag Level Order Traversal BT

## LeetCode – Circular Permutation in Binary Representation (Java)

## Stateless Widget in Flutter

## Stateful Widget in Flutter

## LeetCode – Reverse Words in a String

## Find pair with given difference K in the array

## Find Path with Maximum Gold

## Largest Continuous Sub Array with Zero Sum – Java

## Colorful Number

## LeetCode – Minimum Absolute Difference

## Given an Array of Integers and Target Number, Find Pair having Sum as Target

## Group all anagrams from a given array of Strings

## Test SOAP Web Service using Eclipse

## Consume SOAP Web Service with wsimport

## SOAP Web Service with JAX-WS API

## SOAP Web Services

## Java Memory Profiling with VisualVM

## WebSocket Client API in Java 9 with Example

## HTTP/2 Client in Java 9

## Module Directives in Java 9

## Mediator Design Pattern in Java

## Observer Design Pattern in Java

## Difference between ArrayList and LinkedList

## Chain of Responsibility Design Pattern in Java

## JShell with Example – Java 9

## Can You Crack The Code : Riddle Mystery 2

## Can You Crack The Code : Riddle Mystery 1

## Bubble Sort Algorithm

a source of knowledge.

Given a string, sort it in decreasing order based on the frequency of characters. Example 1: Input: “tree” Output: “eert” Explanation: ‘e’ appears twice while ‘r’ and ‘t’ both appear

Given a m * n matrix of ones and zeros, return how many square submatrices have all ones. Example 1: Input: matrix = [ [0,1,1,1], [1,1,1,1], [0,1,1,1]

Given a binary search tree, write a function kthSmallest to find the kth smallest element in it. Example 1: Input: root = [3,1,4,null,2], k = 1 3 / \ 1

Write a class StockSpanner which collects daily price quotes for some stock, and returns the span of that stock’s price for the current day. The span of the stock’s price today is

Given two strings s1 and s2, write a function to return true if s2 contains the permutation of s1. In other words, one of the first string’s permutations is the

Given a string s and a non-empty string p, find all the start indices of p‘s anagrams in s. Strings consists of lowercase English letters only and the length of

Given a singly linked list, group all odd nodes together followed by the even nodes. Please note here we are talking about the node number and not the value in

Given a circular array C of integers represented by A, find the maximum possible sum of a non-empty subarray of C. Here, a circular array means the end of the array connects to the beginning

Implement a trie with insert, search, and startsWith methods. Example: Trie trie = new Trie(); trie.insert(“apple”); trie.search(“apple”); // returns true trie.search(“app”); // returns false trie.startsWith(“app”); // returns true trie.insert(“app”); trie.search(“app”);

Given a non-negative integer num represented as a string, remove k digits from the number so that the new number is the smallest possible. Note: The length of num is

You are given a sorted array consisting of only integers where every element appears exactly twice, except for one element which appears exactly once. Find this single element that appears only

An image is represented by a 2-D array of integers, each integer representing the pixel value of the image (from 0 to 65535). Given a coordinate (sr, sc) representing the

In a town, there are N people labelled from 1 to N. There is a rumor that one of these people is secretly the town judge. If the town judge exists, then:

Given a positive integer num, write a function which returns True if num is a perfect square else False. Note: Do not use any built-in library function such as sqrt.

You are given an array coordinates, coordinates[i] = [x, y], where [x, y] represents the coordinate of a point. Check if these points make a straight line in the XY plane. Example

In a binary tree, the root node is at depth 0, and children of each depth k node are at depth k+1. Two nodes of a binary tree are cousins

Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times. You may assume that the array

Given a string, find the first non-repeating character in it and return it’s index. If it doesn’t exist, return -1. Examples: s = “leetcode” return 0. s = “loveleetcode”, return

Given a positive integer, output its complement number. The complement strategy is to flip the bits of its binary representation. Example 1: Input: 5 Output: 2 Explanation: The binary representation

Given an arbitrary ransom note string and another string containing letters from all the magazines, write a function that will return true if the ransom note can be constructed from

You’re given strings J representing the types of stones that are jewels, and S representing the stones you have. Each character in S is a type of stone you have.

You are a product manager and currently leading a team to develop a new product. Unfortunately, the latest version of your product fails the quality check. Since each version is

Given a binary tree where each path going from the root to any leaf form a valid sequence, check if a given string is a valid sequence in such binary tree.

Given a non-empty binary tree, find the maximum path sum. For this problem, a path is defined as any sequence of nodes from some starting node to any node in

Given a 2D binary matrix filled with 0’s and 1’s, find the largest square containing only 1’s and return its area. Example: Input: 1 0 1 0 0 1 0

(This problem is an interactive problem.) A binary matrix means that all elements are 0 or 1. For each individual row of the matrix, this row is sorted in non-decreasing order. Given a row-sorted binary matrix

Return the root node of a binary search tree that matches the given preorder traversal. (Recall that a binary search tree is a binary tree where for every node, any descendant

Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand. (i.e., [0,1,2,4,5,6,7] might become [4,5,6,7,0,1,2]). You are given a target value to search. If

Given a string containing only three types of characters: ‘(‘, ‘)’ and ‘*’, write a function to check whether this string is valid. We define the validity of a string

Given a binary array, find the maximum length of a contiguous subarray with equal number of 0 and 1. Example 1: Input: [0,1] Output: 2 Explanation: [0, 1] is the

We have a collection of stones, each stone has a positive integer weight. Each turn, we choose the two heaviest stones and smash them together. Suppose the stones have weights x and y

Given a range [m, n] where 0 <= m <= n <= 2147483647, return the bitwise AND of all numbers in this range, inclusive. Example 1: Input: [5,7] Output: 4

You have a queue of integers, you need to retrieve the first unique integer in the queue. Implement the FirstUnique class: FirstUnique(int[] nums) Initializes the object with the numbers in the

Given two strings S and T, return if they are equal when both are typed into empty text editors. # means a backspace character. Note that after backspacing an empty text, the text will continue

You are given a string s containing lowercase English letters, and a matrix shift, where shift[i] = [direction, amount]: direction can be 0 (for left shift) or 1 (for right shift). amount is the amount by which

Write an algorithm to determine if a number n is “happy”. A happy number is a number defined by the following process: Starting with any positive integer, replace the number

Say you have an array prices for which the ith element is the price of a given stock on day i. Design an algorithm to find the maximum profit. You

Given an array nums of n integers where n > 1, return an array output such that output[i] is equal to the product of all the elements of nums except

Given two strings text1 and text2, return the length of their longest common subsequence. A subsequence of a string is a new string generated from the original string with some

Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path. Note:

Given a binary tree, you need to compute the length of the diameter of the tree. The diameter of a binary tree is the length of the longest path between

Design a stack that supports push, pop, top, and retrieving the minimum element in constant time. 1. push(x) — Push element x onto stack. 2. pop() — Removes the element

Given a non-empty, singly linked list with head node head, return a middle node of linked list. If there are two middle nodes, return the second middle node. Example 1: Input: [1,2,3,4,5] Output:

Given an integer array arr, count element x such that x + 1 is also in arr. If there’re duplicates in arr, count them seperately. Example 1: Input: arr = [1,2,3]

Given an array of non-negative integers, you are initially positioned at the first index of the array. Each element in the array represents your maximum jump length at that position.

Given a 2d grid map of ‘1’s (land) and ‘0’s (water), count the number of islands. An island is surrounded by water and is formed by connecting adjacent lands horizontally

Given an array of integers and an integer k, you need to find the total number of continuous subarrays whose sum equals to k. Example 1: Input:nums = [1,1,1], k

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

Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: get and put. get(key) – Get the value (will always be positive)

Given an array nums, write a function to move all 0’s to the end of it while maintaining the relative order of the non-zero elements. Example: Input: [0,1,0,3,12] Output: [1,3,12,0,0]

Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum. Example: Input: [-2,1,-3,4,-1,2,1,-5,4], Output: 6 Explanation: [4,-1,2,1]

Given a non-empty array of integers, every element appears twice except for one. Find that single one. Note: Your algorithm should have a linear runtime complexity. Could you implement it

Given a binary tree, invert the binary tree and return it. Look at the example for more details. Mirror of a Tree: Mirror of a Binary Tree T is another

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).

Given 2 integers n and start. Your task is return any permutation p of (0,1,2…..,2^n -1) such that : p[0] = start p[i] and p[i+1] differ by only one bit

Before beginning development with Flutter, one should familiar with Widgets like Stateless and Stateful. Today we will talk on Stateless Widget. Stateless Widget As the name suggests, Stateless widgets are immutable. Stateless widgets remain

When building Flutter apps, most of the time we are dealing with widgets. Widgets are everywhere in Flutter. Flutter uses widgets to describe reusable building blocks in the user interface.

Given an input string, reverse the string word by word. Example 1: Input: “the sky is blue” Output: “blue is sky the” Example 2: Input: ” hello world! ” Output:

Given an array A of integers and another non-negative integer K, find if there exist 2 indices i and j such that A[i] – A[j] = K, i != j.

In a gold mine grid of size m * n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is

Find the largest continuous sequence in an array which sums to zero. Example: Input: { 1 , 3 , -1 , 2 , -4 , 1} Output: {3 , -1

For Given Number N find if its COLORFUL number or not Number is COLORFUL number if product of every digit of a contiguous subsequence is different. A number can be

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

Given an array of integers A[], find two numbers such that they add up to a specific target number B. The program should return indices of the two numbers such

Given an array of strings, return all groups of strings that are anagrams. Represent a group by a list of integers representing the index in the original list. Look at

Overview In a previous article, we have created SOAP Web service with JAX-WS API. Also, we have covered different ways to consume or test SOAP Web Service. Today we will

Overview In a previous article, we have created SOAP Web service with JAX-WS API. Next part is how can we consume it in Java, How to create stub files or

Overview In the previous article we have gone through an overview of SOAP web service and advantage and disadvantage of it. In today’s article, we will create SOAP web service

Overview As per W3C, web service can be defined as, a software system designed to support interoperable machine-to-machine interaction over a network. Web services are: 1. Platform independent 2. Designed

Overview In the previous article, we navigate through jmap tool to analyze application performance, jmap is a console based which did not have a visual interface to analyze the data,

Overview WebSocket API is another addition to the java.httpclient package in Java 9. As explained earlier, it enables having full duplex communication between the client and the server. This package

Overview In Java 9, Oracle has released a new version of HTTP client API which will support HTTP/2 protocol and WebSocket features. As existing HTTP Client API has numerous issues

Overview We have discussed Java 9 Modularity and Module System. Also we have discussed How to create first Module in Java 9 using eclipse. Here we will discuss in detail

Overview Mediator design pattern is a behavioral design pattern. It is used to provide a centralized communication medium between different objects in a system. The Gang of Four has indicated

Overview Observer Pattern is a behavioral type design pattern. According to GoF, the observer design pattern is; The observer pattern defines a one-to-many dependency between objects so that when one

1. Memory Allocation ArrayList uses Array as underline datastructure to store the elements, and we know Array stores elements in consecutive manner. In LinkedList, elements can be stored at any

Overview Chain of Responsibility Pattern can be used when we want to give more than one object a chance to handle a request. The pattern can be used to achieve

Java 9 introduces JShell and a Read-Eval-Print Loop (REPL) for the Java Programming Language. REPL allows us to evaluate code snippets such as declarations, statements, expressions. We can test our

Can You Crack The Code Riddle Mystery 2 In this article “Can You Crack The Code Riddle Mystery 2”, you will find very interesting Riddle Mystery. A Number Lock has

Can You Crack The Code Riddle Mystery 1 In this article “Can You Crack The Code Riddle Mystery 1”, you will find very interesting Riddle Mystery. A Number Lock has

Bubble Sort Algorithm Bubble sort algorithm, sometimes referred to as sinking sort, is a simple sorting algorithm that repeatedly steps through the list to be sorted, compares each pair of