tag:blogger.com,1999:blog-6849619265483407528.post1336982173234236357..comments2024-03-28T05:31:17.862-07:00Comments on Programming Interview Questions and Answers: How to find if a number is a Palindrome?Nikhil Singhalhttp://www.blogger.com/profile/03662183414943720702noreply@blogger.comBlogger25125tag:blogger.com,1999:blog-6849619265483407528.post-43259452163957113572021-01-15T01:48:50.028-08:002021-01-15T01:48:50.028-08:00Đại lý vé máy bay Aivivu
vé máy bay đi Mỹ
vé máy...Đại lý vé máy bay Aivivu<br /><br /><a href="https://aivivu.com/ve-may-bay-di-my-us-gia-re-bao-nhieu-tien/" rel="nofollow">vé máy bay đi Mỹ</a><br /><br /><a href="https://aivivu.com/ve-may-bay-tu-my-ve-viet-nam-gia-re/" rel="nofollow">vé máy bay từ mỹ về việt nam</a><br /><br /><a href="https://aivivu.com/ve-may-bay-tu-canada-ve-viet-nam-gia-re/" rel="nofollow">lịch bay từ canada về việt nam</a>Huongkvhttps://www.blogger.com/profile/09167457771171306382noreply@blogger.comtag:blogger.com,1999:blog-6849619265483407528.post-22081710941540505412020-11-17T12:06:00.877-08:002020-11-17T12:06:00.877-08:00Thanks for sharing information to our knowledge, i...Thanks for sharing information to our knowledge, it helps me plenty keep sharing… <br /><br /><a href="https://prwatech.in/apache-spark-training-institute-in-pune/" rel="nofollow"> Apache Spark Training in Pune </a><br /><a href="https://prwatech.in/apache-spark-training-institute-in-pune/" rel="nofollow"> Spark Training Institute in Pune </a>Mohd Shariquehttps://www.blogger.com/profile/04899266769471022618noreply@blogger.comtag:blogger.com,1999:blog-6849619265483407528.post-48093549291552505802018-03-29T06:57:14.606-07:002018-03-29T06:57:14.606-07:00شركة مكافحة النمل الابيض بحائل شركة مكافحة حشرات...<a href="https://www.sh2hab.com/%D9%85%D9%83%D8%A7%D9%81%D8%AD%D8%A9-%D8%A7%D9%84%D9%86%D9%85%D9%84-%D8%A7%D9%84%D8%A7%D8%A8%D9%8A%D8%B6-%D8%A7%D9%84%D8%A7%D8%B3%D9%88%D8%AF-%D8%A8%D8%AD%D8%A7%D8%A6%D9%84/" rel="nofollow">شركة مكافحة النمل الابيض بحائل</a> <a href="https://www.sh2hab.com/%D9%85%D9%83%D8%A7%D9%81%D8%AD%D8%A9-%D8%A7%D9%84%D8%AD%D8%B4%D8%B1%D8%A7%D8%AA-%D8%A8%D8%AD%D8%A7%D8%A6%D9%Anonymoushttps://www.blogger.com/profile/16533321466369728238noreply@blogger.comtag:blogger.com,1999:blog-6849619265483407528.post-31824960501691763352018-02-11T02:02:26.643-08:002018-02-11T02:02:26.643-08:00try this for numbers very simple logic..
class pal...try this for numbers very simple logic..<br />class palindrom<br />{<br />static void main()<br />{<br />int num,rem,temp,rev=0;<br />Console.WriteLine("eneter no");<br />num=int.parse(Console.ReadLine());<br />num=temp;<br />while(num>0)<br />{<br />rem=num%10;<br />rev=rev*10+rem;<br />num/=10;<br />}<br />if(temp==rev)<br /> WriteLine("no is palindrome");<br />else<br /Anonymoushttps://www.blogger.com/profile/02410415699609642586noreply@blogger.comtag:blogger.com,1999:blog-6849619265483407528.post-43900331908346663232016-10-01T19:45:21.029-07:002016-10-01T19:45:21.029-07:00if(sampleStr==new String(temp)),correct it ;-)
if(sampleStr==new String(temp)),correct it ;-)<br /> Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-6849619265483407528.post-27955762831334157762016-07-20T12:19:01.190-07:002016-07-20T12:19:01.190-07:00using System;
namespace palindrome
{
class Pro...using System;<br />namespace palindrome<br />{<br /> class Program<br /> {<br /> static void Main(string[] args)<br /> {<br /> string s,revs="";<br /> Console.WriteLine(" Enter string");<br /> s = Console.ReadLine();<br /> for (int i = s.Length-1; i >=0; i--) //String Reverse<br /> {<br />Anonymoushttps://www.blogger.com/profile/17198325205246608924noreply@blogger.comtag:blogger.com,1999:blog-6849619265483407528.post-44439426270009445242016-06-08T01:11:17.138-07:002016-06-08T01:11:17.138-07:00I have an doubt I'm new to c# can I just know ...I have an doubt I'm new to c# can I just know to call this method in main method .I don't know how to do that Anonymoushttps://www.blogger.com/profile/08628611378460503285noreply@blogger.comtag:blogger.com,1999:blog-6849619265483407528.post-40926617913300612962015-12-21T04:33:04.020-08:002015-12-21T04:33:04.020-08:00Great Article..
Dot Net Training in Chennai
.Net O...Great Article..<br /><a href="http://wisenitsolutions.com/IT-Courses/Dot-Net-Training" title="Dot Net Training in Chennai" rel="nofollow">Dot Net Training in Chennai</a><br /><a href="http://wisenitsolutions.com/IT-Courses/Dot-Net-Training" title=".Net Online Training" rel="nofollow">.Net Online Training</a><br /><a href="http://wisenitsolutions.com/IT-Courses/Dot-Net-Training" title="ASP.NET navyahttps://www.blogger.com/profile/09650347706574609617noreply@blogger.comtag:blogger.com,1999:blog-6849619265483407528.post-41059774566452294262015-12-04T07:15:44.560-08:002015-12-04T07:15:44.560-08:00Here is the algo to check number is palindrome or ...Here is the algo to check number is palindrome or not <br />1. Reverse the digits of inputNumber, and store it in another integer variable(Let's call it reverseNumber).<br />2. Compare inputNumber and reverseNumber.<br />http://www.techcrashcourse.com/2014/10/c-program-check-palindrome-number.htmlAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-6849619265483407528.post-56878061545273215762015-10-24T09:51:19.516-07:002015-10-24T09:51:19.516-07:00Sure. It would work. But think about the performan...Sure. It would work. But think about the performance implications of your code. What if the string is a million characters long? What complexity and memory pressure are you adding?Nikhil Singhalhttps://www.blogger.com/profile/03662183414943720702noreply@blogger.comtag:blogger.com,1999:blog-6849619265483407528.post-91761300094970559532015-10-23T16:56:56.131-07:002015-10-23T16:56:56.131-07:00What would your impression be of this approach? ...What would your impression be of this approach? <br /><br /> private static bool isPalidrome(int num)<br /> {<br /> return num.ToString() == new string(num.ToString().Reverse().ToArray());<br /> }Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-6849619265483407528.post-45171185400918486302015-09-03T22:57:47.310-07:002015-09-03T22:57:47.310-07:00Good explanation .. Thanks for the post...Good explanation .. Thanks for the post...rajeshhttps://www.blogger.com/profile/13429679916750202470noreply@blogger.comtag:blogger.com,1999:blog-6849619265483407528.post-56880653162771214972014-05-31T00:12:32.656-07:002014-05-31T00:12:32.656-07:00Vivek,
just change insted of i++; write len--; and...Vivek,<br />just change insted of i++; write len--; and else past write palindrome=false;<br />then u r code is working fineAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-6849619265483407528.post-43821293519709962422014-03-25T17:26:59.071-07:002014-03-25T17:26:59.071-07:00haha. Never mind. Duh, 120 reversed is actually 21...haha. Never mind. Duh, 120 reversed is actually 21!! Sorry. Thanks for this great blog and articles. This is helping me a lot!Anonymoushttps://www.blogger.com/profile/07706955998452515548noreply@blogger.comtag:blogger.com,1999:blog-6849619265483407528.post-80785451294466165162014-03-25T17:23:59.311-07:002014-03-25T17:23:59.311-07:00ReverseNumber function doesn't work for number...ReverseNumber function doesn't work for numbers that end in zero. For example try 120 and it returns 21Anonymoushttps://www.blogger.com/profile/07706955998452515548noreply@blogger.comtag:blogger.com,1999:blog-6849619265483407528.post-29033629037122780282013-10-30T07:36:50.742-07:002013-10-30T07:36:50.742-07:00Imad,
The loop will execute 2 times as length/2 is...Imad,<br />The loop will execute 2 times as length/2 is 4/2 = 2 and the counter starts at 0. So, in two iterations, the string will be reversed. I would strongly recommend that you type this code in a program and execute it step by step.Nikhil Singhalhttps://www.blogger.com/profile/03662183414943720702noreply@blogger.comtag:blogger.com,1999:blog-6849619265483407528.post-27131027221806917642013-10-29T22:55:47.616-07:002013-10-29T22:55:47.616-07:00@Nikhil Singhal :
I tried the second example you ...@Nikhil Singhal :<br /><br />I tried the second example you gave in your post above which traverse only half the string. But i think its wrong. because when the user enters a number such as "4254", the variable "isPalin" is considered true, and the for loop breaks out after the firs iteration as numtoStr[0] = 4 and numtoStr[3]=4<br />Anonymoushttps://www.blogger.com/profile/06547343211785180280noreply@blogger.comtag:blogger.com,1999:blog-6849619265483407528.post-21970968521415860982013-10-20T22:58:48.871-07:002013-10-20T22:58:48.871-07:00Let me try this one in ruby:
def palindrome?(n)
...Let me try this one in ruby:<br /><br />def palindrome?(n)<br /> digits = Math.log10(n).to_i + 1<br /> (digits/2).times do |right|<br /> left = digits-1-right<br /> if n/(10*left)%10 != n/(10*right)%10<br /> return false<br /> end<br /> end<br /> return true<br />end<br /><br />Btw, I can't seem to post in safari, but works in chrome....pencilcheckhttps://www.blogger.com/profile/16638047168012677805noreply@blogger.comtag:blogger.com,1999:blog-6849619265483407528.post-85171958642647728122013-08-30T13:16:20.143-07:002013-08-30T13:16:20.143-07:00gayathri,
The goal of this exercise is to not use ...gayathri,<br />The goal of this exercise is to not use built-in functions. You need to show that you understand how the system works underneath and that you can get the best performance possible.Nikhil Singhalhttps://www.blogger.com/profile/03662183414943720702noreply@blogger.comtag:blogger.com,1999:blog-6849619265483407528.post-47876003732734239892013-08-30T13:15:05.837-07:002013-08-30T13:15:05.837-07:00Vivek,
Take a look at the third solution in my pos...Vivek,<br />Take a look at the third solution in my post. Why would you want to traverse the entire length of the string when in fact you can get the answer in half?Nikhil Singhalhttps://www.blogger.com/profile/03662183414943720702noreply@blogger.comtag:blogger.com,1999:blog-6849619265483407528.post-85869635056127866152013-08-28T13:22:02.715-07:002013-08-28T13:22:02.715-07:00class Program
{
static void Main(strin... class Program<br /> {<br /> static void Main(string[] args)<br /> {<br /> Console.WriteLine("enter string");<br /> string name = Console.ReadLine();<br /> Boolean palindrome =false;<br /> int len = name.Length;<br /> for (int i = 0; i < (len - 1); i++)<br /> {<br /> if (name[i] == name[RFhttps://www.blogger.com/profile/09276532564559102377noreply@blogger.comtag:blogger.com,1999:blog-6849619265483407528.post-11624304108255654652013-06-27T18:07:21.599-07:002013-06-27T18:07:21.599-07:00The last solution is so smart :)The last solution is so smart :)Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-6849619265483407528.post-49219573278902325972013-03-06T23:12:48.956-08:002013-03-06T23:12:48.956-08:00Great collection of questions in one plate!Great collection of questions in one plate!gayathrihttps://www.blogger.com/profile/00383814597707077013noreply@blogger.comtag:blogger.com,1999:blog-6849619265483407528.post-35310450999029844792013-03-06T23:11:33.274-08:002013-03-06T23:11:33.274-08:00class Palindrome
{
static void Main()
{
...class Palindrome<br />{<br /> static void Main()<br /> {<br /> string checkStr, sampleStr;<br /> char[] temp;<br /> <br /> System.Console.Write("Enter your String: ");<br /> <br /> sampleStr = System.Console.ReadLine();<br /> <br /> checkStr = sampleStr.Replace(" ", "");<br /> <br /> checkStr = checkStr.ToLower();<br /> <br /> gayathrihttps://www.blogger.com/profile/00383814597707077013noreply@blogger.comtag:blogger.com,1999:blog-6849619265483407528.post-74783715528256680612012-12-11T20:05:40.296-08:002012-12-11T20:05:40.296-08:00Great example!
More examples of programming elega...Great example!<br /><br />More examples of programming elegance please :)Anonymousnoreply@blogger.com