Skip to main content

Tricks to follow while programming

1. Before start coding resolve the algorithm, The better way is to trace the logic that your mind followed already. Because on looking into the problem, your mind will give the solution. You have to know how the mind got that solution, in which way ?
2. We have to remember any time you are not going with Standard increment or decrements, you will loose the control on the flow then you have take it to your hand by using a if condition and break.
3. Here we need to talk about logical AND operator. It will not validate the second condition if the first condition fails. We effectively utilized that feature here. Suppose A && B is there. assume expression A is false, then it will not validate for B, it will go with the false result.
4. I feel we should always be strict to the boundaries, of the problem while developing the solution. 

Comments

Popular posts from this blog

Solution Repeated String Hacker Rank

Challenge: Lilah has a string,  , of lowercase English letters that she repeated infinitely many times. Given an integer,  , find and print the number of letter  a 's in the first   letters of Lilah's infinite string. For example, if the string   and  , the substring we consider is  , the first   characters of her infinite string. There are   occurrences of  a  in the substring. Function Description Complete the  repeatedString  function in the editor below. It should return an integer representing the number of occurrences of  a  in the prefix of length   in the infinitely repeating string. repeatedString has the following parameter(s): s : a string to repeat n : the number of characters to consider Input Format The first line contains a single string,  . The second line contains an integer,  . Constraints For   of ...