
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 10476 Articles for Python

5K+ Views
Suppose we have a string, password. We have to find out minimum changes required to make the password strong. So the password has some following criteria −It must be at least 6 character long and at most 20-character longIt must contain at least one lowercase letter, at least one uppercase letter, and at least one numeric character.It must not contain three repeating characters in a row like …aaa…, …PPP…, …888….So if the input is like "aa26bbb", so we need at least one change, as there is no uppercase letter, and there is three b’s in a row, so we can ... Read More

706 Views
Suppose we have a 2D board and a list of words. So from the dictionary, we have to find all words in the board. Here each word must be constructed from letters of sequentially adjacent cell, where the adjacent cells are those horizontally or vertically neighboring. We have to keep in mind that the same letter cell may not be used more than once in a word.So if the input is like −To solve this, we will follow these steps −make an array resultDefine a method called solve(), this will take board, d, i, j swhen either i or j ... Read More

1K+ Views
Suppose we have a binary tree. We have to find the post order traversal of this tree using the iterative approach. So if the tree is like −Then the output will be: [9, 15, 7, 10, -10]To solve this, we will follow these steps −if root is null, then return empty arraycreate an array retstack := define a stack with pair [root, 0]while stack is not empty −node := top of stack, then delete element from stack.if second value of node pair is 0, thencurrent := first value of node pairinsert a pair (current, 1) into stackif right of current ... Read More

491 Views
Suppose we have a non-empty string s and a dictionary called wordDict, this dictionary is containing a list of non-empty words, add spaces in s to construct a sentence where each word is a valid dictionary word. We have to find all such possible sentences. “appleraincoat” and dictionary is [“app”, “apple”, “rain”, “coat”, “raincoat”]To solve this, we will follow these steps −Create one map memoDefine a method called solve, this will take string and wordDictif s is null, then return empty listif s in memo, then −return memo[s]create an array retfor i in range 1 to size of sif substring ... Read More

5K+ Views
Suppose we have an array of integers. We have to find the length of the longest consecutive elements sequence. So if the input is like [100, 4, 250, 1, 3, 2], answer will be 4, as the longest consecutive sequence is [1, 2, 3, 4].To solve this, we will follow these steps −make the array set, longest := 0for i in range array −if i – 1 is not in a −current := i, streak := 0while i in a −increase i by 1, increase streak by 1longest := max of longest and streakreturn longestExampleLet us see the following implementation ... Read More

929 Views
Suppose we have one non-empty binary tree. We have to find the path sum. So here, a path is any sequence of nodes from some starting node to any node in the where the parent-child connections are present. The path must contain at least one node and does not need to go through the root node. So if the input tree is −Here the output will be 32.To solve this, we will follow these steps −Define one method called solve(), this will take nodeif node is null or the value of node is 0, then return 0left := max of ... Read More

885 Views
Suppose we have one array of integers, where all elements are positive. The initial starting point is at index 1. Each element in the array represents our maximum jump length at that position. Our goal is to reach to the final cell with less number of jumps. So if the array is like [2, 3, 1, 1, 4], and then the output will be 2, as we can jump to index 1 from 0, then jump to index 4, that is the last index.To solve this, we will follow these steps −end := 0, jumps := 0, farthest := 0for ... Read More

4K+ Views
Suppose we have an input string s and another input string p. Here is the main string and p is the pattern. We have to define one method, that can match pattern in the string. So we have to implement this for a regular expression, that supports wildcard characters like ‘?’ And ‘*’.Dot ‘?’ Matches any single characterStar ‘*’ Matches zero or more characters.So for example, if the input is like s = “aa” and p = “a?”, then it will be true, for the same input string, if the patter is “?*”, then it will be true.To solve this, ... Read More

1K+ Views
Suppose we have an array of n non-negative integers. These are representing an elevation map where the width of each bar is 1, we have to compute how much water it is able to trap after raining. So the map will be like −Here we can see there are 6 blue boxes, so the output will be 6.To solve this, we will follow these steps −Define a stack st, water := 0 and i := 0while i < size of heightif is stack is empty or height[stack top] >= height[i], then push i into stack, increase i by 1otherwisex := ... Read More

887 Views
Suppose we have one unsorted integer array; we have to find the smallest missing positive number. So if the array is like [4, -3, 1, -1], then the result will be 2.To solve this, we will follow these steps −set i := 0 and update array nums by adding one 0 before all numbersfor i in range 0 to length of numswhile nums[i] >= 0 and nums[i] < length of nums and nums[nums[i]] is not nums[i] −nums[nums[i]] := nums[i]nums[i] := nums[nums[i]]num := 1for i in range 1 to length of numsif num = nums[i], then increase num by 1return numExampleLet ... Read More