
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 26504 Articles for Server Side Programming

2K+ Views
Suppose we have a sorted array nums, we have to remove the duplicates in-place such that duplicates elements will appear at most twice and return the new length. To do this task we cannot take extra space. We have to solve this with O(1) amount of space. For example, if the array is like [0,0,0,1,1,1,1,2,3,3], then the output will be [0,0,1,1,2,3,3], its length is 7Let us see the steps −len := 2 and n := size of arrayif n

6K+ Views
In Python word search refers to determining if a given word exists in the grid, this can be done using various approaches like DFS method and backtracking algorithm, etc, and the given word can be formed by sequentially connecting adjacent cells both horizontally or vertically. Step Involved The steps involved in performing word search in Python are as follows. Consider the input board(2D grid) Define the class ... Read More

1K+ Views
Suppose we have a set of numbers; we have to generate all possible subsets of that set. This is also known as power set. So if the set is like [1, 2, 3], then the power set will be [[], [1], [2], [3], [1, 2], [1, 3], [2, 3], [1, 2, 3]]Let us see the steps −We will solve this using recursive approach. So if the recursive method name is called solve(), and this takes the set of numbers (nums), temporary set (temp), res and indexThe solve() function will work like below −if index = length of nums, then create ... Read More

489 Views
Here, we have to print 1 2 3 sequences repeatedly infinite number of times using threads in the c programming language.Let’s see the sample output that we want from our code, 1 2 3 1 2 3 1 2 3 1 2 3For this, we will have to use three threads that are running side by side in the C programming language. And a variable that is initialized to one in the first thread whose value will be updated based on its last value. And run an infinite loop in the function.ExampleLet’s see the program to implement our solution, #include ... Read More

423 Views
Suppose we have write an efficient algorithm to searches for a value in one m x n matrix. This matrix has some properties like below −Each row is sorted from left to rightThe first number of each row is greater than the last integer of the previous row.So if the matrix is like −1357101116202330345053627898And if the target value is 16, then the output will be True.Let us see the steps −n := number of rows, if n is 0, then return false, m := number of columns, if m = 0, then return falselow := 0 and high := n ... Read More

195 Views
In this problem, we are given 2 arrays x[] , y[] such that (x, y) gives a cordinate of a point in 2D plane. Our task is to print all points along with their frequencies of occurence.Let’s take an example to understand the problemInput: x[]={0, 1, 1, 0, 0} ; y[]={1, 2, 2, 2, 1} Output (0, 1) = 2 (1, 2) = 2 (0, 2) = 1To solve this problem, we need to store frequency of occurence of each point. So this we need to use map data-structure. The key of the map is (x[i], y[i]), mapped value is ... Read More

2K+ Views
Consider we have a matrix, in that matrix if one element is 0, then make the entire row and column of that matrix to 0. The conversion will be in-place. So if the matrix is −101111111Then the output will be −000101101Let us see the steps −n := number of rows, m := number of columns, set flag := falseif mat[0, 0] = 0, then set flag := trueset row := false, and col := falsefor i in range 1 to nif mat[i, 0] = 0, then set col := True and break the loopfor i in range 1 to mif ... Read More

274 Views
Here, we will see the code that will print a 2D matrix in c/c++ programming language without using curly braces.Curly braces are separators in a programming language that are used to define separate code blocks in the program. Without curly braces defining scopes is difficult in c/c++.Let’s see the basic code and sample output to print 2D matrix.Example Live Demo#include using namespace std; int main() { int arr[2][2] = {{12, 67}, {99, 5}}; int n = 2, m = 2; for (int i = 0; i < m; i++){ for (int j = 0; j < n; j++){ cout

1K+ Views
Suppose we have an absolute path for a file (Like Unix File system), we have to simplify it. Or in other words, we have to convert it to the canonical path. In the UNIX-style file system, a period ‘.’ refers to the current directory. And a double period ‘..’ moves the directory up a level (Parent directory). The properties of canonical paths are as follows.Path must always begin with a slash /There must be only a single slash / between two directory names.Last directory name (if it exists) must not end with a trailing /.Canonical path must be the shortest ... Read More

241 Views
Suppose we have a m x n matrix filled with non-negative integers, find a path from top left corner to bottom right corner which minimizes the sum of all numbers along its path. Movements can only be either down or right at any point in time. So for example, if the matrix is like below131151421The output will be 7, the path will be 1, 3, 1, 1, 1, this will minimize the sumLet us see the steps −a := number of rows, b := number of columnsi := a – 1, j := b - 1while j >= 0matrix[a, j] ... Read More