This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Description: | |
he historic state of Wakanda has various monuments and souveniers which are visited by many travellers every day. The guides follow a prescribed route of visiting the monuments which improves them understand the relevance of each monument. The route of the monument is fixed and expressed in a 2-d matrix where the travellers visit the prescribed next monument. For example | |
1 2 3 | |
4 5 6 | |
7 8 9 | |
is the prescribed route and the visitors travels this path: 1->2->3->4->5->6->7->8->9 | |
However, a certain visitor decides to travel a different path as follows: | |
1. The visitor only plans to visit the upper diagonal triangle of the monument list. | |
2. The visitor travels diagonally till there are no more moves left in the current journey. | |
3. He then visits the adjacent monument to the first monument of current diagonal journey. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Description: | |
Another question that will help you get better understanding of arrays data structure, in this you have to find an element that is smallest in the respective row and largest in the column. Watch video for better understanding. | |
Question Name: | |
Saddle Price | |
Question Link : | |
https://www.pepcoding.com/resources/online-java-foundation/2d-arrays/saddle-price-official/ojquestion | |
Question Statement: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1) Suppose if we are given only the length of string, can you print the number of permutations ? | |
Answer) yes, number permutions are simply equal to the factorial of length of string, like, | |
if we have length of string as 4 then total number of permutations is going to be | |
4 * 3 * 2 * 1 = 24 | |
(think and maditate for more approaches) | |
_________________________________________________________________ | |
2) Can there be a non recursive approach ? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1) Why we use line change outside the inner loops ? | |
Answer) We change the line for once only after executing both inner loops | |
because our inner loops work for the columns, and the outer loop works for the row. | |
_________________________________________________________________ | |
2) Why pattern is not printing properly in case of even input ? | |
Answer) We do not get the desired pattern for even values of 'n' because, for this pattern we increment our stars upto the mid row, | |
but in case of even input, we do not get a proper line for seperation. So, the pattern prints correctly initially, but after the first half | |
the pattern won't look as desired. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1) Why we are travelling through the columns in outer loop ? | |
Answer) We are travelling throught the columns first because if we analyse the problem, then it is clear that the columns are increasing countinuously, while rows are alternating. | |
_________________________________________________________________ | |
2) Why we are checking if column is odd or even ? | |
Answer) We are doing so because, after analysing the pattern, we can figure this relation that for every even value of column, we are going downwards through rows and vice versa. | |
_________________________________________________________________ | |
3) Can we do this with recursion ? | |
Answer) Yes, it can be done as follows : |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1) Why we return a new arraylist/ list/ vector when we hit a wrong position ? | |
Answer) We return a new arraylist/ list/ vector so that means that it is empty, then in that case, | |
we would not be able to traverse it and add any element to it, so it will prevent any wrong paths to be added as answer. | |
_________________________________________________________________ | |
2) Why we add an empty string before returning the new arraylist/ list/ vector when we reach the destination ? | |
Answer) Because when we reach our destination, we need to add that path as our answer, that's why we add an empty string | |
so our list/ arraylist/ vector does not stay empty and we can traverse it. | |
_________________________________________________________________ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1) Which base is the most common and used everywhere? | |
Answer) Base (10) i.e. the decimal number system. | |
2) Why are we multiplying our single digit product with power before adding it to answer ? | |
Answer) We need to multiply it with power, because if you can recall, when we used to product two numbers manually, then after | |
each single digit product when we changed the line, we used to add a trailing 0 to the next single digit product, that's why we use this power. | |
3) How to decide what the carry should be ? | |
Answer) The carry depends upon the base of the numbers that we are working on, so let's say if we are working on base 8, | |
then the carry will be calculated by this formula : carry = num / 8, and the number to keep will be num % 8. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1) Can we add any more functionalities in our OS ? | |
ans) Definitely, and I'll appreciate your efforts if you do so, you can try to | |
tweak this and add simple stuffs like, changing the background image on press of a button. | |
2) How can i integrate a new App into the existing os ? | |
ans) Simply, copy your app source file into the main project directory and modify its main fuction with a name and | |
create another button in the main source file of the project and in its callback, simply call you apps function. | |
3) Why we make variables global here ? | |
ans) we make our necessary variables global here because we need to intigrate multiple files together and |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Q. What are mutable and immutable variables? | |
A. Mutable variables are the ones that can be modified and reassigned, but immutable variables can't be edited after one assignment. | |
Q. What is the difference between val and var? | |
A. var keyword is for creating mutable variables and val is for creating immutable variables. | |
Q. What is explicit type declaration? | |
A. Defining the type of a variable while declaration is explicit type declaration. eg: var a : Int = 10 | |
Q. What is type casting? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Q. What is equals operator? | |
A. equals operator is used to check if two strings are equal. | |
Q. What is the use of string interpolation? | |
A. String interpolation is used to include variables into a string. | |
Q. What is compareTo operator? | |
A. It compares two strings on the basis of its ascii value and provides the output according to the difference of ascii values. | |
Q. What is a range? |