gfg (16)


what the difference between map and hashmap in STL

This question already has an answer here: map vs. hash_map in C++ 5 answers in C++ STL, there are two map, map and hashmap. Anyone know the main difference…


Java Initialization Block

Can someone help me understand the following construct? I am having trouble understanding if this is an initializer or an anonymous class. I am not familiar with this syntax. JTable jt=new JTa…


java - Program hangs if thread is created in static initializer block

I have come across a situation where my program hangs, looks like deadlock. But I tried figuring it out with jconsole and visualvm, but they didn't detect any deadlock. Sample code: public class Stati…


c++ - Why can't I declare a reference to a mutable object?(“reference cannot be declared mutable”)

Let's say we have a test.cpp as follows: class A; class B{private: A mutable&_a;}; Compilation: $> gcc test.cpp test.cpp:6:20: error: reference ‘_a’ cannot be declared ‘mutable’[-fp…


java - Behavior of static blocks with inheritance

I am trying to use static blocks like this: I have a base class called Base.java public class Base{static public int myVar;}And a derived class Derived.java: public class Derived extends Ba…


algorithm - How exactly does a XOR Linked list work?

The following link explains it. The implementation is said to work by storing the XOR of the previous and next address(say nxp), instead of storing both(previous and next address) separately.Howeve…


c++ - Searching a map with upper bound and lower bound

STL newbie question: Regarding functions std::map::upper_bound and std::map::lower_bound is it valid to specify a key that is not actually present in the map? Example std::map<int,int> intmap; std::m…



algorithm - Distinct Subsequences DP explanation

From LeetCode Given a string S and a string T, count the number of distinct subsequences of T in S. A subsequence of a string is a new string which is formed from the original string by deleting…


c++ - Differentiating between const references to immutable vs. mutable objects

Is there any accepted way in C++ to differentiate between const references to immutable objects vs. mutable ones? e.g. class DataBuffer{//...}; class Params{//...}; class C{public:…


Performance penalty using 'auto' keyword in Visual Studio 2010

Using the new auto keyword has degraded my code execution times. I narrowed the problem to the following simple code snippet:#include<iostream>#include<map>#include<vector>#include<deque>#in…




java how python and the program pointer list linked interviewbit