/improving-coding

Easy tasks with easy solutions to improve coding

improving-coding

Easy tasks with easy solutions to improve coding

  1. Write a program to find the middle element of a linked list in one-pass (in C++) - Think about a solution that favours time complexity.
  2. How to determine if an integer is a palindrome? (e.g. 1234321 or 123321 are palindromes) You're allowed to use an extra data structure.
  3. Write a program to calculate n factorial (n!) of integers with and without recursion, e.g. 1x2x3x....xn
  4. Find the biggest integer in an array in the optimal time complexity. O(n)
  5. How do you determine if a point lies inside a triangle?
  6. If you have N doors (that stay closed), in the first round, you have to toggle every door, and the 2nd round, you have to toggle every 2nd door, in the 3rd round, you have to toggle every 3rd door, in the n-th round, you have to toggle every n-th door, how do you implement a program like this? e.g. toggle means if the door is closed, and you toggle it, the door will be opened, if the door is opened and you toggle it, the door will be closed.