Neelavan
BAN USER
- 14of 14 votes
AnswersWrite a program to check whether it is a valid binary tree or not. Check all test cases (e.g. No left Node case).
- Neelavan in United States| Report Duplicate | Flag | PURGE
Amazon SDE-2 Algorithm
public static void RotateString(string myString,int times)
{
char[] myChar = myString.ToArray();
List<char> lst = new List<char>();
int firstStringCount= myChar.Count() - times;
for (int i = firstStringCount; i < myChar.Count(); i++)
{
lst.Add(myChar[i]);
}
for (int i = 0; i < firstStringCount; i++)
{
lst.Add(myChar[i]);
}
lst.ForEach(s=>Console.Write(s));
}
Use a dictionary of rotate values of each integer.
public static void CheckRotationNumber(int myInt)
{
bool flag=true;
Dictionary<int, int> rotateDict = new Dictionary<int, int>();
rotateDict.Add(1, 1); rotateDict.Add(2, 2); rotateDict.Add(3, 3); rotateDict.Add(4, 4);
rotateDict.Add(5, 5); rotateDict.Add(6, 9); rotateDict.Add(7, 7); rotateDict.Add(8, 8); rotateDict.Add(9, 6); rotateDict.Add(0, 0);
char[] myChar = myInt.ToString().ToArray();
int length = myChar.Length-1;
for (int i = 0; i <= length/2; i++)
{
if(rotateDict[myChar[i] - '0'] != myChar[length-i] - '0')
{
flag=false;
break;
}
}
Console.Write(flag.ToString());
}
First track the level of the node and add parent pointer in your tree structure.
static void LeftMostNodeSameLevel(Node myNode)
{
int level = 0;
while (myNode.Parent!=null)
{
myNode = myNode.Parent;
level += 1;
}
while (myNode!=null && level>0)
{
if (myNode.LeftNode != null)
myNode = myNode.LeftNode;
else
myNode = myNode.RightNode;
level-=1;
}
Console.WriteLine("Left Most Node is {0}",myNode.Value);
}
We can keep tracking of previous jump .
public static bool FrogJump(bool[] array)
{
int lastJump = 0;
bool canCross = true;
for (int i = 0; i < array.Count(); i++)
{
if (array[i] == true)
{
int tempJump = 0;
for (int j = 1; j < array.Count()-i; j++)
{
tempJump = j;
if (tempJump > lastJump + 1)
{
canCross = false;
break;
}
if (array[i + tempJump] == false)
{
i = i + j;
break;
}
}
lastJump = tempJump;
}
}
return canCross;
}
It's impossible to do less than O(mn), here is the solution by using DFS recursion.
public static void PrintDFSMatrix(int[,] myInt, int x, int y)
{
if (x < myInt.GetLength(0) && y < myInt.GetLength(1))
{
PrintDFSMatrix(myInt, x + 1, y + 1);
for (int i = y; i < myInt.GetLength(0); i++)
{
Console.WriteLine(myInt[x, i]);
}
for (int i = x + 1; i < myInt.GetLength(1); i++)
{
Console.WriteLine(myInt[i, y]);
}
}
}
RepYaritzaLewis, abc at 8x8
I am working as a receptionist in a Softage company. I work with the HR department to facilitate recruitment drives ...
Repkristenjjimenezk, Analyst at ADP
We Statistical assistants establish and check numerical facts in many different areas of business, government, and industry. Right now I ...
RepRutviOrtiz, Android Engineer at AMD
I am experienced in teaching other translators through one-on-one mentoring and professional development courses. I am passionate about Unbinding spell ...
RepGwen Camacho, Accountant at ABC TECH SUPPORT
Gwen , a Director of Nursing with 6+ years of experience with excellent supervising and organizational skills in a large hospital ...
RepLoisHarvey, Apple Phone Number available 24/7 for our Customers at Absolute Softech Ltd
Working as a Content editor it's almost 10 years at Deco Refreshments, Inc. As a content editor is someone ...
Repdalecronin028, Animator at Pinterest
Hello, I am Dale. I am a Tourist guide who welcomes tourists . Tourist Guides act as ambassadors of the country ...
RepDustinSeals, Accountant at 247quickbookshelp
I am Dustin . Speech-language pathologist in Standard Brands Paint Company. I diagnose and swallow problems. I work with both children ...
Repolliejshea, Android test engineer at ABC TECH SUPPORT
Hello I am an application engineer. I love my work very much. Nowadays I am doing some new experiments. Like ...
Reptracyremly, Anesthesiologist at Ness
I am Tracy, working as an Anesthesiologist handles surgical patients and their pain relief during procedures.Rather than my job ...
RepAchillesDiaz, Digital marketing Experinced at Jabong
I am working as a web administrator. I have a basic understanding of tools for testing HTML, CSS validation, Kerala ...
RepSophiaLopez, Analyst at AMD
I am a skilled freelance graphic designer with over a decade of experience in the field. I am dedicated to ...
Repcarlawbartlett, Accountant at ASU
Managed a small team managing toy elephants for the underprivileged. A real dynamo when it comes to managing vashikaran mantra ...
RepShaneFord, Associate at ABC TECH SUPPORT
ShaneFord , Uniformed police officer working at Kash n' Karry here i Assists in the investigation of crimes and/or suspected ...
RepPhyllisGreene, Developer Advocate at Autonomy Zantaz
Phyllis , a Communication Specialist adept at executing promotion strategies, serving as a spokesperson, developing new communication tools, and analyzing marketing ...
RepOliveDavin, abc at 8x8
Experienced forester working in the industry for over 3 years. Solid background in the management of private and public forest ...
RepJamesSeavey, Android test engineer at ABC TECH SUPPORT
Hey, my name is JamesSeavey and I completed all my study from California. And Nowadays I am working as a ...
RepJudeSandin, Associate at Absolute Softech Ltd
My name is JudeSandin . I am working at Bold Ideas as a Web designer. With 5 years experience . I am ...
RepLizaZeiger, Animator at Accenture
I am a Loan processing clerk. My work is assembling, administering and processing your loan application paperwork before it gets ...
RepAadavKiva, abc at 8x8
By profession I am a blogger and passionate about writing new and informative blog content who easily understand visitors. Nowaday ...
RepAmaraPerez, Android Engineer at Allegient
I am an outgoing and motivated flight attendant with a strong customer-oriented approach and excellent communication skills.I am always ...
Repcloptonchirsty, Android Engineer at 8x8
Hello, I am an Organic chemist and my all study and degree is complete from New York.Apart from this ...
Repmariadbulter222, Android Engineer at ABC TECH SUPPORT
Hey, I am a corporate investigator. I love this work. My hobby like write story and different types of article ...
Repmarksloan761, Backend Developer at Apache Design
As a Meeting manager at Red Bears Tavern here I am working for approximately ten years . In my daily life ...
RepJohnPitts, Development Support Engineer at Barclays Capital
John , an urban regional planner with over four years of experience helping cities and local areas to properly plan for ...
Repjepatricia581, Accountant at 247quickbookshelp
We business management is the coordination and organization of business activities. Business managers oversee operations and help employees reach their ...
RepAngelinaJolly, Member Technical Staff at Bankbazaar
Angelina , a Trustworthy Head Housekeeper with extensive experience in leading a large housekeeping team, hiring and training new staff and ...
Repheldagale, Backend Developer at ASU
Helda , an outgoing Library Assistant capable of working independently in a busy library environment. Great team player adept at performing ...
RepNancy , a Homemaker manages the household of the various families. I love to explore astrology so I recently took help ...
Reppetersmith36788, Animator at ABC TECH SUPPORT
I am working at Eden Lawn Service as a Bridge and lock tender . Here I manage all the things like ...
Replesamean618, Android Engineer at Adap.tv
Working as a Choreographer it's almost 10 years at Happy Bear Investment . Here I am dealing with different people ...
RepRuizLeslie, Management accountant at Omni Superstore
Ruiz , a Management accountant with 4 years in the field of administrative functions, managing the office of the Leadership team ...
RepBriannaWright, Analyst at A9
I am a skilled project manager with years of exemplary service in diverse IT roles. I am passionate about utilizing ...
Repcolleenpbeverly02, Android test engineer at ABC TECH SUPPORT
Hello I am Colleen Dedicated and hardworking Geographic information specialist analyst with 15 years of experience working with ArcGIS software ...
Repdeborahdond, Rehabilitation counsellor at Parts salesperson
Hello, I am Deborah Rehabilitation counsellors who help people with physical, mental, developmental, or emotional disabilities live independently. I want ...
RepRomiTerry, Member Technical Staff at Cleartrip.com
Romi , a Dynamic Property Manager highly regarded for increasing and maintaining a high level of occupancy adhering to all regulations ...
RepAadhilDiaz, Accountant at A9
I have a knowledgeable and experienced history professor looking to obtain a position in which to impact students and improve ...
Repchomeshgeles, Android Engineer at ABC TECH SUPPORT
ReevesMildr , a builder working at Independent Investors . It has been almost 5 years since I have been working here. I ...
RepBravoDwayne, Blockchain Developer at ADP
Bravo , a Broker Assistant skilled at assisting financial advisors and stockbrokers in any tasks as required. As I love to ...
RepSimonPister, Blockchain Developer at Absolute Softech Ltd
Simon , a food scientist , records the Tracking status of all existing ingredients during the review and updating process and communicates ...
RepFernBryant, Android Engineer at ABC TECH SUPPORT
I FernBryant working at Naugles as a Financial consultant . I have 5 years of experience . I also guide people regarding ...
RepNorinaKen, iOS Developer at ASU
Norina, a certified ENP and Emergency Medical Dispatcher with 7 + years of work experience got the opportunity to join the ...
Count Sort
- Neelavan April 09, 2017