![]() If(!str || typeof str != 'string' || str. Using this array is like using string buffer in some server side languages. if string is null or other than string this will fail. i can use an array and also add some checking. advance knowledge about the relationship between data items allows designing of efficient algorithms for the manipulation of data. Is there any different way, you can reverse a string?Īnswer: sure. An array is the most fundamental data structure, which stores elements at a contiguous memory location. What is data structure a data structure is a way of organizing data that considers not only the items stored, but also their relationship to each other. Interviewer: You know concatenation performed well in modern browsers but becomes slow in older browsers like IE8. Question: How would you reverse a string in JavaScript?Īnswer: I can loop through the string and concatenate letters to a new string try 1 If you are not applying for a Research post, you would be alright. As a computer science graduate, its expected from a program to have strong knowledge of both basic data structures, like the array, linked list, binary tree. Decision: divisor would be less than Math.sqrt (n)ĭon't worry! if you didnt get it.It is not divisible by 5, divisor should be less than 127/5 approximately 25 not by 7. So, you will check up to 127/3 approximately 42. 127 is not divisible by 2 hence you should check upto 63.5. step-3: For example u have the number 127.Decision: a number could be divisible by numbers 1/3 of its value. ![]() if you take an even number like 36 it will never be divisible by 13, 14, 15 hence it will be never divisible by any number bigger than 35/3 will never be divisible by 12, 13, 14. ![]() then it would be divisible any number bigger than the 1/3 of its value. (if it is divisible by 3, then it wouldn't be a prime number).
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |