Leet code problem 1415: – The k-th Lexicographical String of All Happy Strings of Length n Medium

A happy string is a string that: For example, strings “abc”, “ac”, “b” and “abcbabcbcb” are all happy strings and strings “aa”, “baa” and “ababbc” are not happy strings. Given two integers n and k, consider a list of all happy strings of length n sorted in lexicographical order.Return the kth string of this list…

Leet code problem 1414: – Find the Minimum Number of Fibonacci Numbers Whose Sum Is K Medium

Given an integer k, return the minimum number of Fibonacci numbers whose sum is equal to k. The same Fibonacci number can be used multiple times. The Fibonacci numbers are defined as: It is guaranteed that for the given constraints we can always find such Fibonacci numbers that sum up to k. Example 1: Input:…

Leet Code problem 1410: – HTML Entity Parser

HTML entity parser is the parser that takes HTML code as input and replace all the entities of the special characters by the characters itself. The special characters and their entities for HTML are: Given the input text string to the HTML parser, you have to implement the entity parser. Return the text after replacing…

Leetcode problem 1409:- Queries on a Permutation With Key

Given the array queries of positive integers between 1 and m, you have to process all queries[i] (from i=0 to i=queries.length-1) according to the following rules: Return an array containing the result for the given queries. Example 1: Input: queries = [3,1,2,1], m = 5Output: [2,1,2,1]Explanation: The queries are processed as follow:For i=0: queries[i]=3, P=[1,2,3,4,5],…

How to access the collection elements using the streams?

Streams is introduced in java8 version. It basically helps to write a concise piece of code and it’s functional style of code writing. For the complete piece of code please visit the below mentioned link. The piece of code for stream iteration is mentioned below :- In the above case the “forEach” is a terminal…

How to access collection elements in java using iterator method?

Iterator is a method which returns an iterator over elements. It is defined inside the “Iterable” interface of java collection framework. The source code of this interface can be found in the below mentioned link. Let’s create on collection of hotels as mentioned in the below mentioned code:- The source code of the “Hotel” class…