Problem Statement :
Given an array of integers
numsand an integer
target, return indices of the two numbers such that they add up to
You may assume that each input would have exactly one solution, and you may not use the same element twice.
You can return the answer in any order.
The brute force way :
Pick an element and then loop over the entire list to find if target minus element exists. This will be O(N²) time and we can do better.
Single Pass :
We can combined looking for the pair of indices into a…
Convert a non-negative integer
numto its English words representation.
Input: num = 123
Output: "One Hundred Twenty Three"
Input: num = 12345
Output: "Twelve Thousand Three Hundred Forty Five"
Input: num = 1234567
Output: "One Million Two Hundred Thirty Four Thousand Five Hundred Sixty Seven"
Input: num = 1234567891
Output: "One Billion Two Hundred Thirty Four Million Five Hundred Sixty Seven Thousand Eight Hundred Ninety One"
You may have noticed I have highlighted a few keywords in the examples. Try to look for some sort of pattern before you proceed.