Posts

Do you know how does 𝙎𝙥𝙧𝙞𝙣𝙜𝘼𝙥𝙥𝙡𝙞𝙘𝙖𝙩𝙞𝙤𝙣.𝙧𝙪𝙣() work internally?

Image
    The 𝙎𝙥𝙧𝙞𝙣𝙜𝘼𝙥𝙥𝙡𝙞𝙘𝙖𝙩𝙞𝙤𝙣 class provides a convenient way to bootstrap a Spring application that is started from a main() method. By default, 𝙎𝙥𝙧𝙞𝙣𝙜𝘼𝙥𝙥𝙡𝙞𝙘𝙖𝙩𝙞𝙤𝙣 class will perform the following steps to bootstrap your application: 1. Creates an 𝙚𝙢𝙥𝙩𝙮 𝙀𝙣𝙫𝙞𝙧𝙤𝙣𝙢𝙚𝙣𝙩 𝙤𝙗𝙟𝙚𝙘𝙩. 2. Find the external configuration file like 𝙖𝙥𝙥𝙡𝙞𝙘𝙖𝙩𝙞𝙤𝙣.𝙥𝙧𝙤𝙥𝙚𝙧𝙩𝙞𝙚𝙨 / 𝙖𝙥𝙥𝙡𝙞𝙘𝙖𝙩𝙞𝙤𝙣.𝙮𝙢𝙡 from the classpath of the application and load these properties into the environment object. 3. Print 𝙎𝙥𝙧𝙞𝙣𝙜 𝘽𝙖𝙣𝙣𝙚𝙧. 4. Identifies the type of the application by using property 𝙒𝙚𝙗𝘼𝙥𝙥𝙡𝙞𝙘𝙖𝙩𝙞𝙤𝙣𝙏𝙮𝙥𝙚 and instantiates an appropriate IOC Container. 5. Instantiates the 𝙎𝙥𝙧𝙞𝙣𝙜𝙁𝙖𝙘𝙩𝙤𝙧𝙞𝙚𝙨 and register with IOC Container. 6. Initialise the IOC Container by executing 𝘼𝙥𝙥𝙡𝙞𝙘𝙖𝙩𝙞𝙤𝙣𝘾𝙤𝙣𝙩𝙚𝙭𝙩𝙄𝙣𝙞𝙩𝙞𝙖𝙡𝙞𝙯𝙚𝙧. 7. Prepare the context by 𝙋𝙧𝙚𝙥𝙖𝙧𝙚𝘾𝙤𝙣𝙩𝙚𝙭𝙩. 8. Refresh the context by 𝙍𝙚𝙛𝙧

Coding Problem 7: Techfest and the Queue [GFG - Problem Solving]

  A Techfest is underway, and each participant is given a ticket with a unique number. Organizers decide to award prize points to everyone who has a ticket ID between  a  and  b  ( inclusive ). The points given to a participant with ticket number  x  will be the  sum of powers of the prime factors  of  x . For instance, if points are to be awarded to a participant with ticket number  12 , the amount of points given out will be equal to  the sum of powers in the prime factorization  of  12  ( 2 2  × 3 1 ), which will be  2 + 1 = 3 . Given  a  and  b , determine the sum of all the points that will be awarded to the participants with ticket numbers between  a  and  b  ( inclusive ). Example 1: Input: a = 9 b = 12 Output: 8 Explanation: For 9, prime factorization is:3 2 So, sum of the powers of primes is: 2 For 10, prime factorization is : 2 1 x5 1 So, sum of the powers of primes is: 2 For 11, prime factorization is : 11 1 So, sum of the powers of primes is: 1 For 12, prime factoriz

Coding Problem 6: Count possible ways to construct buildings [GFG - Problem Solving]

  There is a road passing through a city with   N   plots on both sides of the road. Plots are arranged in a straight line on either side of the road. Determine the   total number  of ways to construct buildings in these plots, ensuring that no two buildings are adjacent to each other. Specifically, buildings on opposite sides of the road cannot be adjacent. Using  *  to represent a plot and  ||  for the road, the arrangement for  N = 3  can be visualized as follows:  * * * || * *  *. Note:  As the answer can be very large, print it  mod 10 9 +7 . Example 1: Input: N = 1 Output: 4 Explanation: Possible ways for the arrangement are B||*, *||B, B||B, *||* where B represents a building. Example 2: Input: N = 3 Output: 25 Explanation: Possible ways for one side are BSS, BSB, SSS, SBS, SSB where B represents a building and S represents an empty space. Pairing up with possibilities on the other side of the road, total possible ways are 25. Your Task: You don't need to read or print anyt

Coding Problem 5: Find element occuring once when all other are present thrice [GFG - Problem Solving]

  Given an array of integers   arr[]   of length   N , every element   appears   thrice  except for one which   occurs   once . Find that element which  occurs   once . Example 1: Input: N = 4 arr[] = {1, 10, 1, 1} Output: 10 Explanation: 10 occurs once in the array while the other element 1 occurs thrice. Example 2: Input: N = 10 arr[] = {3, 2, 1, 34, 34, 1, 2, 34, 2, 1} Output: 3 Explanation: All elements except 3 occurs thrice in the array. Your Task: You do not need to take any input or print anything. You task is to complete the function  singleElement () which takes an array of integers  arr  and an integer  N  which finds and returns the element  occuring once  in the array. Constraints: 1 ≤ N ≤ 10 5 -10 9  ≤ A[i] ≤ 10 9 Expected Time Complexity:  O(N). Expected Auxiliary Space:  O(1). Solution : Repository:  coding-problems:  https://github.com/nileshkadam222/coding-problems/blob/master/src/com/coding/problems/gfg/ElementOccuringOnce.java package com.coding.problems.gfg ; i

Coding Problem 4: Smallest window containing 0, 1 and 2 [GFG - Problem Solving]

  Given a string   S   consisting of the characters   0 ,   1   and   2 . Your task is to find the length of the   smallest substring  of string   S   that contains all the three characters   0, 1  and   2 . If no such substring exists, then return   -1 . Example 1: Input: S = 10212 Output: 3 Explanation: The substring 102 is the smallest substring that contains the characters 0, 1 and 2. Example 2: Input: S = 12121 Output: -1 Explanation: As the character 0 is not present in the string S, therefor no substring containing all the three characters 0, 1 and 2 exists. Hence, the answer is -1 in this case. Your Task: Complete the function  smallestSubstring()  which takes the string  S  as input, and returns the length of the  smallest substring  of string S that contains all the three characters  0, 1  and  2. Expected Time Complexity:  O( length( S ) ) Expected Auxiliary Space:  O(1) Constraints: 1 ≤ length( S ) ≤ 10 5 All the characters of String S lies in the set {'0', &#

Coding Problem 3 - Weather Observation Station 7 [HackerRank - SQL]

Image
  Query the list of   CITY   names ending with vowels (a, e, i, o, u) from   STATION . Your result   cannot   contain duplicates. Input Format The  STATION  table is described as follows: where  LAT_N  is the northern latitude and  LONG_W  is the western longitude. Notes :  SUBSTR() The SUBSTR() function extracts a substring from a string (starting at any position). Note:  The SUBSTR() and  MID()  functions equals to the  SUBSTRING()  function. Syntax SUBSTR( string ,  start ,  length ) Parameter Values Parameter Description string Required. The string to extract from start Required. The start position. Can be both a positive or negative number. If it is a positive number, this function extracts from the beginning of the string. If it is a negative number, this function extracts from the end of the string length Optional. The number of characters to extract. If omitted, the whole string will be returned (from the  start  position) RIGHT() The RIGHT() function extracts a number of chara