Skip to content

Instantly share code, notes, and snippets.

  1. Queue with two stacks. Implement a queue with two stacks so that each queue operations takes a constant amortized number of stack operations. Hint: If you push elements onto a stack and then pop them all, they appear in reverse order. If you repeat this process, they're now back in order.

  2. Stack with max. Create a data structure that efficiently supports the stack operations (push and pop) and also a return-the-maximum operation. Assume the elements are reals numbers so that you can compare them. Hint: Use two stacks, one to store all of the items and a second stack to store the maximums.

  3. Java generics. Explain why Java prohibits generic array creation. Hint: to start, you need to understand that Java arrays are covariant but Java generics are not: that is, String[] is a subtype of Object[], but Stack<String> is not a subtype of Stack<Object>.

Q. How does auto-boxing handle the following code fragment?

Integer a = null;
int b = a;

A. It results in a run-time error. Primitive type can store every value of their corresponding wrapper type except null.

Q. Why does the first group of statements print true, but the second false?

Integer a1 = 100;

Introduction

A simple portal for tracking testing reports, bugs found and then mapping all this way back to features and releases. However JIRA and other such project management tools provide the features that are mentioned in this document but still this solution can come in handy for those who don't want an outside tool rather a quick dirty solution.
Note this is for a general solution overview and focusses more on data modelling. Any installation and setup related findings is homework for reader :)

What all is compassed in testing ?

  1. Testing Report
  2. Bugs
  3. Releases
  4. Features
@anandrajneesh
anandrajneesh / Demo.java
Created April 11, 2017 07:16
Demonstration - Buggy hashcode can create a havoc in Hashmap
import java.util.HashMap;
import java.util.Map;
/**
* Created by Anand_Rajneesh on 4/3/2017.
*/
public class Demo {
public static void main(String[] args) {
Map<Key,String> map = new HashMap<>();
@anandrajneesh
anandrajneesh / mongo.md
Last active May 26, 2017 06:31
Mongo queries just for reference
db.people.aggregate([
{
    $lookup : {
        from :"companies",
        localField:"company_id",
        foreignField:"_id",
        as : "companys"
    }
},
@anandrajneesh
anandrajneesh / Driver.java
Created July 9, 2017 06:35
Connection pooling
package org.gluecoders.multithreading.cp;
import java.util.stream.IntStream;
public class Driver {
public static void main(String[] args) {
try {
Thread.sleep(20000);
int max = (int) (Math.random()*100);
@anandrajneesh
anandrajneesh / Windows scripts.md
Last active November 1, 2017 18:47
Windows scripting

Windows scripting gists

@anandrajneesh
anandrajneesh / springhibernate.md
Created November 7, 2017 02:14
Spring Boot Hibernate

spring.datasource.url=jdbc:mysql://localhost:3306/test
spring.datasource.username=root
spring.datasource.password=root
spring.jpa.show-sql=true
spring.jpa.hibernate.ddl-auto=update
spring.jpa.hibernate.naming-strategy=org.hibernate.cfg.ImprovedNamingStrategy
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect

@Autowired