Posts

Showing posts from June, 2018

java 9 concurrent Flow

JDK 1.9 concurrent Flow

Longest Palindromic Substring

Problem statement: Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000. import java.io.IOException; public class LongestSubstringPalindrome {   public static void main(String[] args) throws IOException   {     // String word = "abbcbba";     String str = "abbagoodteacher";     System.out.println(longestPalindrome(str));   }   public static String longestPalindrome(String s)   {     int length = s.length();     if (s == null || length < 2)     {       return s;     }     boolean isPalindrome[][] = new boolean[length][length];     int left = 0;     int right = 0;     for (int j = 1; j < length; j++)     {       for (int i = 0; i < j; i++)       {         boolean isInnerWordPalindrome = ...

java 9 : Publisher, Subscriber, Subscription and Processor

How do you do search in an array where difference between adjacent elements is k

Problem statement: How do you do efficient search in an array where difference between adjacent elements is k public class JumpSearchWithKDiff { public static void main(String[] args) { int a[] = { 2, 4, 6, 8, 6, 4, 2, -1, -3 }; int s = -3; // 's' is the element to be searched int k = 2; // diff. b/w element int n = a.length; // length of array System.out.println("Element " + s + " is present at index " + searchAlgo (a, n, s, k)); } static int searchAlgo (int a[], int n, int s, int k) { // scan the given array staring from leftmost element int i = 0; while (i < n) { // check if element is found if (a[i] == s) return i; // else jump to diff. b/w current array element & search element // divided by k We use max here to make sure that i moves at-least one step ahead i = i + Math.abs(a[i] - s) / k; // i = i + Math.max(1, Math.abs(a[i] - s) / k); } System.out.println("number is ...

Find number in a array, where after sometime array is decreasing.

Find number in a array, where after sometime array is decreasing if element present in array return"exist" else "not exist" Example: array- [1,3,5,8,9,10,6,5,4,3,3,2,1,0]; find 4 time completely better than O(n)

How do you create tree data structure ?

/* Class containing left and right child of current node and data value*/ class Node { int  data ; Node   left ,  right ; public  Node (int  data1 ) { data  =  data1 ; left = right = null ; } } // A Java program to introduce Binary Tree class BinaryTree { // Root of Binary Tree Node   root ; // Constructors BinaryTree (int data1) { root  = new  Node (data1); } BinaryTree () { root  = null; } public static void main(String[] args) { BinaryTree   tree  = new  BinaryTree (); /*create root*/ tree . root  = new  Node ( 1 ); /* following is the tree after above statement                  1              /   \            null   null   ...

Create 2 pillars of equal maximum height from an array of bricks

Create two sub array of maximum equal height from an array. Problem Statement: There are N bricks (a1, a2, ...., aN). Each brick has length L1, L2, ...., LN). Make 2 highest parallel pillars (same length pillars) using the bricks provided. Constraints: There are N bricks. 5<=N<=50 Length of each brick. 1<=L<=1000 Sum of the bricks lengths <= 1000 Length of the bricks is not given in size order. There may be multiple bricks which may have the same length. Not all bricks have to be used to create the pillars. Example: 1st Example- N = 5 2, 3, 4, 1, 6 Possible Sets: (2, 6) and (3, 4, 1) Answer: 8 2nd Example- N = 6 1, 5, 1, 6, 1, 1 Possible Sets: (6, 1) and (1, 5, 1) Answer: 7 Solution: import java.util.*; public class KNumberSubset { private int number; private int sum; private LinkedList<Integer> subset; private int[] numbers; static LinkedList<LinkedList<Integer>> all=new LinkedList<>(); public KN...

Today Walkins 14th june

Image
1. Experis IT Private Limited Hiring For Cyber Security | Direct Walkin Qualification:- - B.E/B.Tech Graduates (CSE,ISE/IT Only) - 2017 PASSOUT(S) - 2018 (Only if results are out) - Should have 65% and above in their Education.(10th, 12th and B.Tech Individually) Interview Date:- 14th, 15th June 2018 Venue: Manpower Group - 3rd floor Experis Pvt Ltd.,Chancery Pavilion Annexe, 135 & 136, Residency Road,Richmond Circle, Behind Chancery Pavilion, Bangalore, 560025 Regs.Timin  - 9:30 AM To 2:00 PM Contact Person:- Pratik Mitra(7019270573) Google Map:  https://goo.gl/maps/S6QLqzMXJ6A2 ====================================== 2. Ionidea Interactive Private Limited Hiring for Data Entry Operator | Direct Walkin Qualification : PUC, any Graduation, (No B.E & B.Tech/M.Tech/MBA) Skill sets: 1. Good Typing speed (40+) 2. Knowledge of Microsoft Excel 3. Internet Browsing. Date of interview: 14th to 15th 2018 from 10.00AM 3.00PM Venue: IonId...
 Consider the following pairs :    Tradition                               State 1. Chapchar Kut festival   -  Mizoram 2. Khongjom Parba ballad - Manipur 3. Thang-Ta dance            - Sikkim Which of the pairs given above is/are correct ? (a) 1 only (b) 1 and 2 (c) 3 only (d) 2 and 3
 Consider the following statements: 1. As per the Right to Education (RTE) Act, to be eligible for appointment as a person would be required to possess the minimum qualification laid down by the concerned State Council of Teacher Education. 2. As per the RTE Act, for teaching primary classes, a candidate is required to pass a Teacher Eligibility Test conducted in accordance with the National Council of Teacher Education guidelines. 3. In India, more than 90% of teacher education institutions are directly under the State Governments. Which of the statements given above is/are correct ? (a) 1 and 2 (b) 2 only (c) 1 and 3 (d) 3 only

how do you configure/connect remote desktop from Ubuntu to Ubuntu machine?

press super key(windows) in keyboard type: remote select Remmina Remote Desktop Client choose VNC in dropdown enter the end user machine IP address click connect enter the password of end user machine

how do you check IP address in Ubuntu?

open terminal & type any of the below command > ifconfig > ip add show 

RTC java client user work resource allocation

Read work resource allocation to the user in projectarea and teamarea // Create this object before accessing the api IContributorHandle iContributorHandle; ITeamRepository repo; ITeamAreaHandle teamAreaHendle; IProgressMonitor monitor; IResourcePlanningClient resourcePlanningClient; IContributor contributor =         (IContributor) repo.itemManager().fetchCompleteItem(iContributorHandle, IItemManager.DEFAULT, null);     System.out.println(contributor.getName() + " " + contributor.getUserId());     IContributorInfo info =         resourcePlanningClient.getResourcePlanningManager().getContributorInfo(contributor, true, monitor);     ItemCollection<IWorkResourceDetails> workDetails = info.getWorkDetails(contributor);     long totalResource = 0;     for (IWorkResourceDetails iWorkResourceDetails : workDetails) {    ...

RTC java client required services and Client classes initialization

    Before accessing any RTC server side Components you have initialize the required services and client classes Below are the Few List of services and client classes initialization(If any other classes you need then add it)       IWorkItemClient iWorkitemClient = (IWorkItemClient) repo.getClientLibrary(IWorkItemClient.class);       IQueryClient iQueryClient = (IQueryClient) repo.getClientLibrary(IQueryClient.class);       IProcessClientService iProcessService =           (IProcessClientService) repo.getClientLibrary(IProcessClientService.class);       IAuditableClient iAuditClient = (IAuditableClient) repo.getClientLibrary(IAuditableClient.class);       IWorkItemCommon workItemCommon = (IWorkItemCommon) repo.getClientLibrary(IWorkItemCommon.class);       IAuditableCommon iA...

RTC java client Login to Server

RTC java client Login to Server List of import for Client dev The First step is login into RTC server using client api     IProgressMonitor monitor = new NullProgressMonitor();     String repositoryURI = args[0];     final String userId = args[1];     final String password = args[2];     TeamPlatform.startup();     try {       ITeamRepository repo = TeamPlatform.getTeamRepositoryService().getTeamRepository(repositoryURI);       repo.registerLoginHandler(new ILoginHandler2() {         @Override         public ILoginInfo2 challenge(final ITeamRepository repo) {           return new UsernameAndPasswordLoginInfo(userId, password);         }       });     ...

List of useful import for RTC dev

 import java.net.URI; import java.text.DecimalFormat; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.NullProgressMonitor; import com.ibm.team.apt.internal.client.resource.IResourcePlanningClient; import com.ibm.team.process.client.IProcessClientService; import com.ibm.team.process.common.IDevelopmentLineHandle; import com.ibm.team.process.common.IIteration; import com.ibm.team.process.common.IProjectArea; import com.ibm.team.process.common.ITeamArea; import com.ibm.team.process.common.ITeamAreaHandle; import com.ibm.team.repository.client.IItemManager; import com.ibm.team.repository.client.ILoginHandler2; import com.ibm.team.repository.client.ILoginInfo2; import com.ibm.team.repository.client.ITeamRepository; import com.ibm.team.repository.client.TeamPlatform; import com.ibm.team.repository.client.login.UsernameAndPasswordLoginInfo; import com.ibm.te...

what do you mean by reflection in java?

Image
Problem statement: what do you mean by reflection in java? Reflection is an API which is used to examine or modify the behaviour of methods, classes, interfaces at Runtime. The required classes for reflection are provided under java.lang.reflect package. Reflection gives us information about the class to which an object belongs and also the methods of that class which can be executed by using the object. Through reflection we can invoke methods at runtime irrespective of the access specifier used with them. Reflection can be used to get information about – Class  The getClass() method is used to get the name of the class to which an object belongs. Constructors  The getConstructors() method is used to get the public constructors of the class to which an object belongs. Methods  The getMethods() method is used to get the public methods of the class to which an objects belongs.
With reference to the Parliament of India, which of the following Parliamentary Committees scrutinizes and report to the House whether the powers to make regulation, rules, sub-rules, by-laws, etc. conferred by the Constitution or delegated by the Parliament are being properly exercised by the Executive within the scope of such delegation? (a) Committee on Government Assurances  (b) Committee on Subordinate Legislation (c) Rules Committee  (d) Business Advisory Committee
Regarding Wood's Dispatch, which of the following statements are true? 1. Grants-in-Aid system was introduced. 2. Establishment of universities was recommended. 3. English as a medium of instruction at all levels of education was recommended. Select the correct answer using the code given below: (a) 1 and 2 only (b) 2 and 3 only (c) 1 and 3 only (d) 1, 2 and 3

LinkedHashSet

Problem statement: what do you mean by LinkedHashSet in collection? LinkedHashSet is the child class of HashSet Introduced in 1.4 version LinkedHashSet is exactly same as HashSet except the following difference HashSet: The underlying data structure is Hashtable Insertion order is not preserved Introduced in 1.2 version LinkedHashSet: The underlying data structure is Hash table + Linked List(this is hybrid data structure) Insertion order is preserved Introduced in 1.4 version
Very recently. in which of the following countries have lakhs of people either suffered from severe famine/acute malnutrition of dies due to starvation caused by war/ethnic conflicts? (a) Angola and Zambia (b) Morocco and Tunisia (c) Venezuela and Colombia (d) Yemen and South Sudan
The identity platform ‘Aadhaar’ provides open “Application Programming Interfaces (APIs)”. What does it imply ? 1. It can be integrated into any electronic device 2. Online authentication using iris is possible. Which of the statements given above is/are correct ? (a) 1 only (b) 2 only (c) Both 1 and 2 (d) Neither 1 nor 2
Consider the following statements : 1. Capital Adequacy Ratio (CAR) is the amount that banks have to maintain in the form of their own funds to offset any loss that banks incur if the account-holders fail to repay dues. 2. CAR is decided by each individual bank. Which of the statements given above" is/are correct ? (a) 1 only (b) 2 only (c) Both 1 and 2 (d) Neither 1 nor 2.
Which one of the following links all the ATMs in India ? (a) Indian Banks Association (b) National Securities Depository Limited (c) National Payments Corporation of India (d) Reserve Bank of India
“Rule of Law Index” is released by which Of the following ? (a) Amnesty International (b) International Court of Justice (c) The Office of UN Commissioner for Human Rights (d) World Justice Project
Which of the following has/have shrunk immensely/dried up in the recent past due to human activities ? 1. Aral Sea 2. Black Sea 3. Lake Baikal Select the correct answer using the code given below : (a) 1 only (b) 2 and 3 (c) 2 only (d) 1 and 3
Consider the following statements : 1. Aadhaar card can be used as a proof of citizenship or domicile. 2. Once issued, Aadhaar number can not be deactivated or omitted by the Issuing Authority. Which of the statements given above is/are correct ? (a) 1 only (b) 2 only (c) Both 1 and 2 (d) Neither 1 nor 2
He Wrote biographies of Mazzini, Garibaldi, Shivaji and Shrikrishna; stayed in America for some time and was also elected to the Central Assembly. He was (a) Aurobihdo Ghosh (b) Bipin Chandra Pal (c) Lala Lajpat Rai  (d) Motilal Nehru
Consider the following statements : 1. The quantity of imported edible oils is more than the domestic production of edible oils in the last five years. 2. The Government does not impose any customs duty on all the imported edible oils as a special case. Which of the statements given above is/ are correct. (a) 1 only (b) 2 only (c) Both 1 and 2 (d) Neither 1 nor 2
Consider the following statements : 1. The Fiscal Responsibility and Budget Management (FRBM) Review Committee Report has recommended a debt to GDP ratio of 60% for the general (combined) government by 2023, comprising 40% for the Central Government and 20% for the State Governments. ' 2. The Central Government has domestic liabilities of 21% of GDP as compared to that of 49% of GDP of the State Governments. 3. As per the Constitution of India, it is mandatory for a State to take the Central Government’s consent for raising any loan if the former owes any outstanding liabilities to the latter. Which of the statements given above is/are correct ? (a) 1 only (b) 2 and 3 only (C) 1 and 3 only (C) 1, 2 and 3
With reference to India’s decision to levy an equalization tax of 6% on online advertisement services offered by non-resident entities. Which of the following statements is/are correct ? 1. It is introduced as a part of the, Income Tax Act. 2. Non-resident entities that offer advertisement services in India can claim a tax credit in. their home country under the “Double Taxation Avoidance Agreements". Select the correct answer using the code given below (a) 1 only (b) 2 only (c) Both 1 and 2 (d) Neither 1 nor 2