DSA 2 Medium

DSA 2 Medium


longest common prefix in a stringGaurav saha
longest common prefix in a stringGaurav saha
next greater element in arraydanish khan
print the string with capital initial lettersdanish khan
whats are the different types of OOP's conceptsJohn Rabindranath
what is polymorphism? explainJohn Rabindranath
what is inheritance? explainJohn Rabindranath
what are class and object?John Rabindranath
if Class A extends by Class B and Class b extends by Class C, whose constructor is needed to be called in class C? What type of Inheritance is that?John Rabindranath
what is a string?John Rabindranath
what is difference between concat() and + operator in string?John Rabindranath
what is a string constant pool?John Rabindranath
what are the different built in functions in string?John Rabindranath
what are linked list? explain different types of linked list?John Rabindranath
what are stack and queue? explain different operation in stacks and queue?John Rabindranath
what is stack.peek() in stack?John Rabindranath
Write a program using reverse a string? example: Jan o/p: naJJohn Rabindranath
write a program to insert a node in the middle of a linked list (use custom linkedlist for better understanding)John Rabindranath
Where are the strings were stored? in stack or in heap memory?John Rabindranath
what is method overloading and method overriding?John Rabindranath
Longest substring without repeating charecter(leetcode)SUMIT SAURAV
Longest substring without repeating charecter(leetcode)SUMIT SAURAV
What is linkedlist and different types of linkedlistSushant Thakur
What are the differences between arrays and linkedlistSushant Thakur
WAP to add elements from array to linkedlistSushant Thakur
WAP to delete elements from linkedlistSushant Thakur
When should I use stack or queue over arrays/linkedlistSushant Thakur
Implement stack using linkedlistSushant Thakur
WAP to implement queueSushant Thakur
WAP to reverse the position of words in an arraysSushant Thakur
Differences between stack and queuesSushant Thakur
WAP to check parenthesis are balanced or not
Given the head of a sorted linked list, delete all duplicates such that each element appears only once. Return the linked list sorted as well.santanu mohanty
2. Given an array nums containing n distinct numbers in the range [0, n], return the only number in the range that is missing from the arraysantanu mohanty
Given two strings s and t, return true if they are equal when both are typed into empty text editors. '#' means a backspace character.pulkit jain
Note that after backspacing an empty text, the text will continue empty.pulkit jain
Given the head of a singly linked list, return true if it is a palindrome.pulkit jain
Swap the kth node from end of linked list [geeksforgeek]Tarun pandey
Rearrange list (even odd) [geeksforgeek]Tarun pandey
Palindorme stringTarun pandey
Linkedlist cycle( node from where the cycle starts)Tarun pandey
Flatten the double linkedlist with child pointerTarun pandey
Remove duplicated from sorted linkedlist ||Tarun pandey
Manish Shaw
Given a string as an input. We need to write a program that will print all non-empty substrings of that given string.Manish Shaw
\Manish Shaw
Examples :Manish Shaw
Manish Shaw
Input : abcdManish Shaw
Output : aManish Shaw
bManish Shaw
cManish Shaw
dManish Shaw
abManish Shaw
bcManish Shaw
cdManish Shaw
abcManish Shaw
bcdManish Shaw
Manish Shaw
Manish Shaw
Q.Longest Common Prefix using Word by Word MatchingManish Shaw
Given a set of strings, find the longest common prefix.Manish Shaw
Examples:Manish Shaw
Manish Shaw
abcd
Input : {“geeksforgeeks”, “geeks”, “geek”, “geezer”}Manish Shaw
Output : "gee"Manish Shaw
Manish Shaw
Input : {"apple", "ape", "april"}Manish Shaw
Output : "ap"Manish Shaw
Manish Shaw
Q.Move all occurrences of an element to end in a linked listManish Shaw
Given a linked list and a key in it, the task is to move all occurrences of the given key to the end of the linked list, keeping the order of all other elements the same.
Examples:
Input : 1 -> 2 -> 2 -> 4 -> 3
key = 2
Output : 1 -> 4 -> 3 -> 2 -> 2
Input : 6 -> 6 -> 7 -> 6 -> 3 -> 10
key = 6
Output : 7 -> 3 -> 10 -> 6 -> 6 -> 6
1. Intersection of Two Linked Lists(Leetcode)
Suraj Mall
2.Valid Anagram(Leetcode)
Suraj Mall
1.Explain the Linked List data structure?Love Arora
2.What is difference between Doubly Linked List and Circular Linked List?Love Arora
3.Difference between Stack & Queue?Love Arora
4.Discuss any application of Doubly Linked List?Love Arora
5.Implement an algorithm, Given a singly linked list of characters, write a function that returns true if the given list is a palindrome, else false.Love Arora
LL: 1-> 2-> 2-> 1Love Arora
Output: trueLove Arora
LL: 1-> 3>-4>->1Love Arora
Output: falseLove Arora
6.Create LL without any library.Love Arora
- What are Data Structures and Algorithms? How do you differentiate them?Durga Chowdary Edara
- What are Strings and what is String immutability?Durga Chowdary Edara
- Write a program for checking if a String is a Palindrome or not?Durga Chowdary Edara
- What are Linked Lists? How are they different from Arrays?Durga Chowdary Edara
- What is the difference between Single and Doubly Linked Lists?Durga Chowdary Edara
- Implement a program to add 1 to a number represented as a Linked List?Durga Chowdary Edara
Input - 9 -> 9Durga Chowdary Edara
Output - 1 -> 0 -> 0Durga Chowdary Edara
Input - 8 -> 7 -> 3Durga Chowdary Edara
Output - 8 -> 7 -> 4Durga Chowdary Edara
- What are stacks? What is the time complexity of pushing an element into the stack?Durga Chowdary Edara
Rotate list by K placesAman Jain
What are Data Structures ?
What are the types of DS ?
what is class, object?
what is static, public, void?
what is stack, queue.
diff b/w array and linkedlist.

WAP to find if string is palindrome or not?

https://leetcode.com/problems/reverse-linked-list/
Ashish Bhalala
Question: Given a singly linked list, find the middle of the linked list. For example, if the given linked list is 1->2->3->4->5 then the output should be 3.Rounak Goliya
If there are even nodes, then there would be two middle nodes, we need to print the second middle element. For example, if given linked list is 1->2->3->4->5->6 then the output should be 4.Rounak Goliya
Rounak Goliya
Question: Given a singly linked list of characters, write a function that returns true if the given list is a palindrome, else false.Rounak Goliya
Rounak Goliya
Question: Number is represented in linked list such that each digit corresponds to a node in linked list. Add 1 to it. For example 1999 is represented as (1-> 9-> 9 -> 9) and adding 1 to it should change it to (2->0->0->0)Rounak Goliya
Rounak Goliya
Rounak Goliya
Rounak Goliya
1. What is a string as per your understanding
2. Is string a dataType in Java?
3. How many objects will be created for the below code
String firstString = "Gaurav";
String secondString = "Gaurav";
String thirdString = new String("Gaurav");

4. Please provide the output for the below code

public static void main(String[] args) {
String firstString = "Gaurav";
String secondString = "Gaurav";
String thirdString = new String("Gaurav");
System.out.print("Case 1 : ");
System.out.println(firstString == secondString);

System.out.println(firstString == thirdString);System.out.print("Case 2 : ");

System.out.print("Case 3 : ");
System.out.println(firstString.equals(thirdString));
}

5. Is string immutable or mutable? Why String is immutable?

6. What is a linkedlist?
7. What does each node of the LinkedList?
8. What is doubly LinkedList
9. Time complexity of insertion, deletion, traversing and searching in single linkedlist and doubly linkedlist

10. Explain stack and queue

DSA

Given a string s, reverse only all the vowels in the string and return it.

The vowels are 'a', 'e', 'i', 'o', and 'u', and they can appear in both cases.

Input: s = "hello"
Output: "holle"

Input s = "oceian"
Output: "acieon"
Kush Hingol
https://www.interviewbit.com/java-string-interview-questions/kush Hingoal --- study from this link to get full knowledge on string
String AnagramNikhil Arwindbhai Butani
Delete Kth node from LinkedListNikhil Arwindbhai Butani
Implement queueNikhil Arwindbhai Butani
Implement stackNikhil Arwindbhai Butani
1. https://leetcode.com/problems/remove-nth-node-from-end-of-list/submissions/Hiren Patel
2. https://leetcode.com/problems/letter-combinations-of-a-phone-number/Hiren Patel
ii)What's algorithm??Hiren Patel
1. whats string?Hiren Patel
2.What is Linked List?Hiren Patel
3.What is Stack and where it can be used?
4.What is a Queue, how it is different from the stack?Hiren Patel
1. Reverse a Linked List.Hardik Singh
1. What is string constant pool?
NIRAJ KUMAR
2. How java manages memory for string.
3. How many object will be created in both the statement.
String str = "hello";
String str = new String("hello");
4. What is the basic difference between the == and .equals()
5. You have given a string and a key, you have to find the number of time key has occurred in the string.
String str = "heyone hey hello heyhey"
key = "hey"
output: 4
6. iWhat s the basic difference between array and linked list?
7. You have given 2 linked list , both are merging at one junction. Task is to find the element where both are merging.
8. How to implement queue using stack.
9. Given an expression string exp, write a program to examine whether the pairs and the orders of “{“, “}”, “(“, “)”, “[“, “]” are correct in exp.
Input: exp = “[()]{}{[()()]()}”
Output: Balanced
Input: exp = “[(])”
Output: Not Balanced
1. Implement a stack using an array.
Dev Mittal Time 08:00 - 09:00pm
2. Next smaller number.
Q1. Program to print all substrings of a given string.
Manish Shaw Time 08:00 - 09:00pm
Given a string as an input. We need to write a program that will print all non-empty substrings of that given string.
Examples :
Input : abcd
Output : a
b
c
d
ab
bc
cd
abc
bcd
abcd
Q2. Longest Common Prefix using Word by Word Matching.s
Given a set of strings, find the longest common prefix.
Examples:
Input : {“geeksforgeeks”, “geeks”, “geek”, “geezer”}
Output : "gee"
Input : {"apple", "ape", "april"}
Output : "ap"
implement queue from stackGurdeep Singh Mittal
1. https://leetcode.com/problems/reverse-linked-list/Ashim Kaushal
2. https://leetcode.com/problems/valid-parentheses/Ashim Kaushal
3. https://leetcode.com/problems/longest-common-prefix/Ashim Kaushal
Write a function detectAndRemoveLoop() that checks whether a given Linked List contains a loop and if loop is present then removes the loop and returns true. If the list doesn’t contain a loop then it returns false.Shubham Madheysia
Example:Shubham Madheysia
Input: 1 ⇒ 2 ⇒3 ⇒ 4 ⇒ 5 ⇒ 6 ⇒ 3Shubham Madheysia
Output: 1 ⇒ 2 ⇒3 ⇒ 4 ⇒ 5 ⇒ 6 ⇒nullShubham Madheysia
Explanation: 6 is connected to 3 which makes 3 ⇒4 ⇒5 ⇒6 in loopShubham Madheysia
Note: Write complete code and not just function. This would help us in running and debugging it effectivelyShubham Madheysia
------------------------------------------Shubham Madheysia
Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring.Shubham Madheysia
Input: s = "(()"Shubham Madheysia
Output: 2Shubham Madheysia
Explanation: The longest valid parentheses substring is "()".Shubham Madheysia
Input: s = "(()(()()"Shubham Madheysia
Output: 4Shubham Madheysia
Explanation: The longest valid parentheses substring is "()()".Shubham Madheysia
Input: s = ""Shubham Madheysia
Output: 0Shubham Madheysia
Note: You don’t have to count all valid pairs and sum it up. You need to hunt for the longest contiguous substring which is valid overallShubham Madheysia
String Anagram // completedNikhil Arvindbhai Butani
String Anagram // completedNikhil Arvindbhai Butani
String Anagram // completedNikhil Arvindbhai Butani
String Anagram // completedNikhil Arvindbhai Butani
1. Check if there is a loop in linked listDalchand Kumawat
2. Check if two strings are anagrams.Dalchand Kumawat
3. Implement queue using stack.Dalchand Kumawat
1. Given a string S, find the length of the longest substring without repeating characters.Nikhil Devarasetty
2. Remove loop in a single linked list
3. Reverse alternate k nodes in a singly linked list
1. What is a string as per your understandingkush hingol
2. Is string a dataType in Java?kush hingol
3. How many objects will be created for the below codekush hingol
String firstString = "Gaurav";kush hingol
String secondString = "Gaurav";kush hingol
String thirdString = new String("Gaurav");kush hingol
kush hingol
4. Please provide the output for the below codekush hingol
kush hingol
public static void main(String[] args) {kush hingol
String firstString = "Gaurav";kush hingol
String secondString = "Gaurav";kush hingol
String thirdString = new String("Gaurav");kush hingol
System.out.print("Case 1 : ");kush hingol
System.out.println(firstString == secondString);kush hingol
System.out.print("Case 2 : ");kush hingol
System.out.println(firstString == thirdString);kush hingol
kush hingol
System.out.print("Case 3 : ");kush hingol
System.out.println(firstString.equals(thirdString));kush hingol
}kush hingol
kush hingol
5. Is string immutable or mutable? Why String is immutable?kush hingol
kush hingol
6. What is a linkedlist?kush hingol
7. What does each node of the LinkedList?kush hingol
8. What is doubly LinkedListkush hingol
9. Time complexity of insertion, deletion, traversing and searching in single linkedlist and doubly linkedlistkush hingol
kush hingol
10. Explain stack and queuekush hingol
kush hingol
DSAkush hingol
kush hingol
Given a string s, reverse only all the vowels in the string and return it.kush hingol
kush hingol
The vowels are 'a', 'e', 'i', 'o', and 'u', and they can appear in both cases.kush hingol
kush hingol
Input: s = "hello"kush hingol
kush hingol
kush hingol
Input s = "oceian"kush hingol
Output: "acieon"kush hingol
delete the middle of the linked list. ( 2) if even delete two middle nodes if odd delete one middle node ..... only these two questions he is asking do slowly.anirban paul
What is array , What is linked list , Stack , queue?Subham jaiswal
2. diff between array and arrayList in javaSubham jaiswal
3. memory distribution for array , arrayList , LinkedList in javaSubham jaiswal
4. reverse words of string java using split and stackSubham jaiswal
reverse a linked listShubham Bajpai
reverse a linked list in groups of KShubham Bajpai
Question: Given a singly linked list, find the middle of the linked list. For example, if the given linked list is 1->2->3->4->5 then the output should be 3.
If there are even nodes, then there would be two middle nodes, we need to print the second middle element. For example, if given linked list is 1->2->3->4->5->6 then the output should be 4.

Question: Given a singly linked list of characters, write a function that returns true if the given list is a palindrome, else false.

Question: Number is represented in linked list such that each digit corresponds to a node in linked list. Add 1 to it. For example 1999 is represented as (1-> 9-> 9 -> 9) and adding 1 to it should change it to (2->0->0->0)
1)Explain linked list and different types of linked list -- Answered
2)Explain how linked list is different from array -- Answered
3)Write a program to implement queue using two stacks -- No knowledge
4)A celebrity is a person who is known to all but does not know anyone at a party. If you go to a party of N people, find if there is a celebrity in the party or not.

A square NxN matrix M[][] is used to represent people at the party such that if an element of row i and column j is set to 1 it means ith person knows jth person. Here M[i][i] will always be 0.

Note: Follow 0 based indexing.

Example 1:
Input:
N = 3
M[][] = {{0 1 0},
{0 0 0},
{0 1 0}}

Output: 1
Explanation: 0th and 2nd person both
know 1. Therefore, 1 is the celebrity.
20 mins

Example 2:
Input:
N = 2
M[][] = {{0 1},
{1 0}}

Output: -1

Explanation: The two people at the party both know each other. None of them is a celebrity.
-- Not solved
Expected Time Complexity: O(N)
Expected Auxiliary Space: O(1)

5)Write a program to implement the stack using singly linked list -- not solved
Sashidhar
reverse words and it's char also
ex , i have very bad luck
kcul dab yrev evah iMahima Yadav
reverse linked listMahima Yadav
What is linked list and its types
What is stack and queue
Program to check string is palindrome or not
Implement linked list and reverse it
shashankchodhary choudhary
1. Given a linked list, reverse it.
2. Valid anagram - Leetcode.
3. Given a string, remove all the occurrences of 'a' and 'z' from it.
4. Given a string, count the no. of vowels in it.
Ashim Kaushal
https://leetcode.com/problems/reverse-linked-list-ii/Utkarsh Jain
what is difference between array and linked list.
Some question around linked list.
1. Given a linked list detect if there a loop in the linked list or not. (Unable to answer)
2. Given a linked list find the middle element of the linked list. (Correct with code)
3. Given a linked list finr the k th element from the last. (Correct with code)
Interviewer - Sathvik Bhandar
Date - 6:00 pm - 6:55 pm, Aug 26th 2022
1.Explain string
2.What is linked lists
3.What are types of linked lists
4.Explain each type in detail..
5. Explain stack and queue....
6.Write code to implement linked list and write logic to reverse it.
7. remove duplicate and rotate linked list
using scanner class...
Shivam Singh
1. Implement queue data structure.
Dalchand Kumawat
2. Identifying duplicates in linked list.
What is a Stack ? Push and pop implementation
pavan bhansali
Write a program to create a linked list.
Write a program to reverse the linked list.
1. Explain multidimensional arrays
2. types and difference between all types of linked list.
3. Output of following code-
String str = "Hi";
System.out.println(str+10+20);Soumya Pandith
System.out.println(11+22+str);
System.out.println(11+33+str+22+56);
4. Coding question - Given a string, find the minimum number of characters to be inserted to convert it to palindrome.
Given a stack of integers, how do you check whether each successive pair of numbers in the stack is consecutive or not.
Mithun Kumar S R
{ 1, 2, -1, -2, 4, 5, 90. 89, 50}
1. Introduce yourself
2. Implement a singly linked list data structure
3. Given as a singly linked list, check if the linked list is a palindrome or not?
4. What are the advantages of a linked list
Thompson Naidu
1.What will be the output of the following code snippet for the list 1->2->3->4->5->6?

void solve(struct node* start)
{
if(start == NULL)
return;
printf("%d ", start->data);
if(start->next != NULL )
solve(start->next->next);
printf("%d ", start->data);
}
2.Find the Next Greater Element for every node of the linked list.
Note: For nodes with no next greater element, store -1 in the result.

Examples:

Input: linked list = [2, 1, 5]
Output: [5, 5, -1]

Input: linked list = [2, 7, 4, 3, 5]
Output: [7, -1, 5, 5, -1]
3. Remove duplicates from a sorted linked list.
For example if the linked list is 11->11->11->21->43->43->60 then you should convert the list to 11->21->43->60.
1. Reverse singly Linked List ? 2. Merge 2 singly linked list ?Shubham Bajpai September 2nd 2022
1. https://leetcode.com/problems/valid-anagram/Suraj Mall
2. https://leetcode.com/problems/intersection-of-two-linked-lists/September 4th 2022
3. time and space complexity of above solutions
Take your full name as a string.Sourav Anand
Replace each character of the name by next character. A->BSourav Anand
Sourav Anand
InputSourav Anand
AbhishekSourav Anand
OutputSourav Anand
BcijtiflSourav Anand
Sourav Anand
InputSourav Anand
SauravSourav Anand
OutputSourav Anand
TbvsbwSourav Anand
Sourav Anand
2) Implement a linked List with removeFromEnd function.
Stringmandeep kaur
Link list
Hasmaps
) reverse a string using stackVarsha
2) reverse a string without stack
3) Program to Find the Middle Node of a Linked list
[ 1, 45, 5 ,7, 9 , 5]shubham kucheria
[ 2,1,5,6,1,9 ]
Find only unique elements from these 2 arary .
Output: [2, 6, 7, 45],
Find length of linked list with less complexity,
Find 15 elements of Fibonacci series.
1. Given a string s containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.

An input string is valid if:

Open brackets must be closed by the same type of brackets.
Open brackets must be closed in the correct order.
Every close bracket has a corresponding open bracket of the same type.


Example 1:

Input: s = "()"
Output: true
Example 2:

Input: s = "()[]{}"
Output: true
Example 3:

Input: s = "(]"
Output: false
Thompson Naidu
1. Given a string s containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.

An input string is valid if:

Open brackets must be closed by the same type of brackets.
Open brackets must be closed in the correct order.
Every close bracket has a corresponding open bracket of the same type.


Example 1:

Input: s = "()"
Output: true
Example 2:

Input: s = "()[]{}"
Output: true
Example 3:

Input: s = "(]"
Output: false
1. Given a string s containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.

An input string is valid if:

Open brackets must be closed by the same type of brackets.
Open brackets must be closed in the correct order.
Every close bracket has a corresponding open bracket of the same type.


Example 1:

Input: s = "()"
Output: true
Example 2:

Input: s = "()[]{}"
Output: true
Example 3:

Input: s = "(]"
Output: false
What is String?
VIDYA NAYAK
Write a code to check if a given string is palindrome or not.
What is linked list?
What is the difference between linear array and linked list?
What is stack?
Write code to do the stack implementation using linked list.
1. Program to remove vowels from a StringAkash Aggarwal
Input : what is your name ?Akash Aggarwal
Output : wht s yr nm ?Akash Aggarwal
Akash Aggarwal
2. Common characters in n stringsAkash Aggarwal
Akash Aggarwal
orangeAkash Aggarwal
Output : a eAkash Aggarwal
2. What is intern pool?Dilip Rathod
3. What is the basic difference between == and .equals() method?
4. What is the difference between
String str = "Hello";
String str1 = new String("Hello");
5. write a program to reverse given string
6. What is LinkedList?
7. How to detect a loop in the linked list?
1)Write a program to implement the queue using two stacks -- not solved
2)Explain linked list and its types -- Answered
3)Reverse alternate nodes in Link List -- not solved , Syntax Errors
Linked List = 10->4->9->1->3->5->9->4
Given a linked list, you have to perform the following task:
Extract the alternative nodes starting from second node.
Reverse the extracted list.
Append the extracted list at the end of the original list.
4 ,1,5,4 are alternative nodes

o/p: 10-->9-->3-->9-->4-->5-->1-->4-->null
-- not solved
shashidhar
1) Given a program ,Time complexity?Jomish John
2) Output of java string program?
3) Given linked list is Palindrome?
1. Implement Stack using Linked ListShashidhar
2. Delete the current node if the next node is greater than the current nodeShashidhar

 

No comments:

Post a Comment

ads vert

Basic HTML Tables - Layout, HTML Tables, Attributes, Aside, Footer, Tr tag, Td tag, Th tag, Tbody

  Basic HTML Tables - Layout, HTML Tables, Attributes, Aside, Footer, Tr tag, Td tag, Th tag, Tbody < table >      < thead >    ...