ArrayList vs. LinkedList

arraylist-vs-linkedlist-complexity

ArrayList vs. LinkedList   ArrayList is implemented as a resizable array. As more elements are added to ArrayList, its size is increased dynamically. It’s elements can be accessed directly by using the get and set methods, since ArrayList is essentially an array. LinkedList is implemented as a double linked list. Its performance on add and Read More →

What is the Probability that a Knight Stays on Chessboard

knight_moves

Given the size of the chess board and initial position of the knight, what is the probability that after k moves the knight will be inside the chess board. Note:- 1) The knight makes its all 8 possible moves with equal probability. 2) Once the knight is outside the chess board it cannot come back Read More →

Find Largest Area Triangle from 2D Matrix

Problem: Given a table of size n * m, with each cell having a color value from the set {r, g, b}, find the area of the largest triangle that has one side parallel with the y – axis (vertical) and has no two vertices that have the same color value. Input : First line Read More →

Trie Data Structure – C Implementation

Trie Tree: A trie (from retrieval), is a multi-way tree structure useful for storing strings over an alphabet. It has been used to store large dictionaries of English (say) words in spelling-checking programs and in natural-language “understanding” programs. A trie tree uses the property that if two strings have a common prefix of length n Read More →

Implement Stack and Queue using Linked List in Java

The implementation of a linked list is pretty simple in Java. Each node has a value and a link to next node. Two popular applications of linked list are stack and queue. Stack: What is stack? Stack is a linear data structure which implements data on last in first out criteria. Here is a java Read More →

Check for Balanced Parentheses in an Expression

Given a string containing just the characters ‘(‘, ‘)’, ‘{‘, ‘}’, ‘[' and ']‘, determine if the input string is valid. The brackets must close in the correct order, “()” and “()[]{}” are all valid but “(]” and “([)]” are not. Algorithm: 1) Declare a character stack S. 2) Now traverse the expression string exp. Read More →

SAP Labs Interview Questions – Set 3 (On Campus)

Type: Campus Placement Candidate Experience Company: SAP Labs College: NIT Delhi Hi guys , SAP Labs came to our campus. These are some questions they asked me Round 1: Q1. Find Minimum and Maximum of an array in only one traversal. Q2. Given a chessboard find the maximum number of squares present? Q3. What is Read More →

Amazon Interview Questions – Set 10 (SDE 1)

Amazon chennai this years new and latest off and on campus recruitment procedure. College: PSIT Location: Chennai Hi, Recently I was interviewed for the SDE-I for Amazon, Chennai. Some of the questions here I am sharing based on my memory. They were looking for really cool coders. High expectation on accurate answers. looking for deep Read More →

Cousin nodes in Binary Tree

Given the binary Tree and the two nodes say ‘p’ and ‘q’, determine whether the two nodes are cousins of each other or not. Solution: What are cousin nodes ? Two nodes are said to be cousins of each other if they are at same level of the Binary Tree and have different parents. For Read More →

C Programming Quiz – Set 4

Programming Questions and Answers Our C Interview questions come with detailed explanation of the answers which helps in better understanding of C concepts. #1: Predict the output of the following C snippets a) Compiler Error b) Depends on the compiler c) 56 d) none of above Show Answer Answer: c Explanation: main is not a Read More →

Housing.com Interview Questions – Set 1

Company: Housing.com Profile: Software Developer I got a call through recruiter and I was interviewed in March,2015. Round 1: Q1. input: “kitten%20pic.jpg” output: “kitten pic.jpg” %20 -> ‘ ‘ %3A -> ‘?’ %3D -> ‘:’ modify your input in place. no string library functions. void DecodeURL(string str Q2. Given an array, return true, if it Read More →

OLX Interview Questions – Set 1

I got a call through recruiter. My telephonic interview got scheduled. Overall process was very fast. It took not more than 3-4 days till I received offer letter. Telephonic Interview:- Round 1: Q1. Indexes in mysql. Q2. Difference between include_once and require_once? Q3. Constructor and destrutor? Q4. sessions vs cookie. Detailed discussion. Some questions on Read More →