CODOPEDIA Community
787 subscribers
2 photos
3 videos
1 file
78 links
Check all questions and solutions here :
Community.codopedia.in
Download Telegram
to view and join the conversation
A candidate got 5650 votes in an election and won by this opponent by a margin of 3000 votes. if there only two candidates, find the percentage of votes obtained by the defeated candidate.
Anonymous Poll
13%
30.5
47%
31.93
33%
32.65
7%
30.72
If we preempt a resource from a process, the process cannot continue with its normal execution and it must be ____________
Anonymous Poll
15%
aborted
33%
rolled back
26%
terminated
26%
queued
There is a strange printer with the following two special requirements:

The printer can only print a sequence of the same character each time.

At each turn, the printer can print new characters starting from and ending at any places, and will cover the original existing characters.

Given a string consists of lower English letters only, your job is to count the minimum number of turns the printer needed in order to print it.

Example 1:

Input: "aaabbb"
Output: 2
Explanation: Print "aaa" first and then print "bbb".

Example 2:

Input: "aba"
Output: 2
Explanation: Print "aaa" first and then print "b" from the second place of the string, which will cover the existing character 'a'.

Hint: Length of the given string will not exceed 100.
A shop is offering discounts on shirts costing $20 each.If someone buys 2 shirts,he will be offered a discount of 15% on the first shirt and another 10% discount on the reduced price for the second shirt.How much would one pay for two shirts at this shop?
Anonymous Poll
25%
30.3
19%
31.6
38%
32.3
19%
33.3
Which of the join operations do not preserve non matched tuples?
Anonymous Poll
6%
Left outer join
12%
Right outer join
41%
Inner join
41%
Natural join
There are N rooms and you start in room 0.  Each room has a distinct number in 0, 1, 2, ..., N-1, and each room may have some keys to access the next room. 

Formally, each room i has a list of keys rooms[i], and each key rooms[i][j] is an integer in [0, 1, ..., N-1] where N = rooms.length.  A key rooms[i][j] = v opens the room with number v.

Initially, all the rooms start locked (except for room 0). 

You can walk back and forth between rooms freely.

Return true if and only if you can enter every room.

Example 1:

Input: [[1],[2],[3],[]]
Output: true
Explanation: We start in room 0, and pick up key 1. We then go to room 1, and pick up key 2. We then go to room 2, and pick up key 3. We then go to room 3. Since we were able to go to every room, we return true.

Example 2:

Input: [[1,3],[3,0,1],[2],[0]]
Output: false
Explanation: We can't enter the room with number 2.

Note:

1 <= rooms.length <= 1000

0 <= rooms[i].length <= 1000

The number of keys in all rooms combined is at most 3000.
Working 5 hours a day, A can Complete a work in 8 days and working 6 hours a day, B can complete the same work in 10 days. Working 8 hours a day, they can jointly complete the work in:
Anonymous Poll
33%
3 days
25%
4 days
33%
4.5 days
8%
5.4 days
You may recall that an array arr is a mountain array if and only if:

arr.length >= 3

There exists some index i (0-indexed) with 0 < i < arr.length - 1 such that:

arr[0] < arr[1] < ... < arr[i - 1] < arr[i]

arr[i] > arr[i + 1] > ... > arr[arr.length - 1]

Given an integer array arr, return the length of the longest subarray, which is a mountain. Return 0 if there is no mountain subarray.

 

Example 1:

Input: arr = [2,1,4,7,3,2,5]
Output: 5
Explanation: The largest mountain is [1,4,7,3,2] which has length 5.

Example 2:

Input: arr = [2,2,2]
Output: 0
Explanation: There is no mountain.
j is equal to 925 and k is equal to 5,550. A number, n, is added to j, such that the ratio of j+n to k is 1:3. What is the ratio of n to j+n, expressed as a percentage of j+n ?
Anonymous Poll
20%
40
50%
50
0%
60
30%
70
Coding :

Given an array of integers A, find the sum of min(B), where B ranges over every (contiguous) subarray of A.

Since the answer may be large, return the answer modulo 10^9 + 7.

 

Example 1:

Input: [3,1,2,4]
Output: 17
Explanation: Subarrays are [3], [1], [2], [4], [3,1], [1,2], [2,4], [3,1,2], [1,2,4], [3,1,2,4].
Minimums are 3, 1, 2, 4, 1, 1, 2, 1, 1, 1.  Sum is 17.
Coding :

Given an array equations of strings that represent relationships between variables, each string equations[i] has length 4 and takes one of two different forms: "a==b" or "a!=b".  Here, a and b are lowercase letters (not necessarily different) that represent one-letter variable names.

Return true if and only if it is possible to assign integers to variable names so as to satisfy all the given equations.

 

Example 1:

Input: ["a==b","b!=a"]
Output: false
Explanation: If we assign say, a = 1 and b = 1, then the first equation is satisfied, but not the second. There is no way to assign the variables to satisfy both equations.

Example 2:

Input: ["b==a","a==b"]
Output: true
Explanation: We could assign a = 1 and b = 1 to satisfy both equations.

Example 3:

Input: ["a==b","b==c","a==c"]
Output: true

Example 4:

Input: ["a==b","b!=c","c==a"]
Output: false

Example 5:

Input: ["c==c","b==d","x!=z"]
Output: true
Hello guys ,
you can check solution of yesterday's (12th January 2021) task here :
https://community.codopedia.in/daily-tasks/jan/day-12-tasks