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

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

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/co...

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

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