Showing posts with label Java. Show all posts
Showing posts with label Java. Show all posts

Sunday, April 16, 2017

How to find a factorial of a number ?


In mathematics, the factorial of a non-negative integer n, denoted by n!, is the product of all positive integers less than or equal to n. For example,
The value of 0! is 1, according to the convention for an empty product.[1]

Tuesday, April 11, 2017

Reverse a string containing Japaneese and chinese characters


Problem statement: We need to reverse the sentence containing Japanese and Chinese character.

Ex "ABCabcDEFdef . Here we need to assume that the capital letters are Japanese and smaller letters are Chinese.

We need to get an o/p as "defDEFabcABC"

Steps involved

  • Write function to identify if the character is Chinese or Japanese character
  • Check if previous character is different than the current. If it is different then add a space
  • Use split and then reverse the string
  • Remove the empty space