You are not logged in. Please login at to post your questions!


Why is it showing runtime error SIGSTP?

All submissions for this problem are available.You have a stack which is initially empty. You receive instructions of the form 1 or 0. 1 denotes that you have to push in an element, and 0 denotes that you have to pop out an element. But of course you can pop something out only if it exists in the stack. So your job is to look at the instructions and see if they are valid (ie. you never have to pop from an empty stack), or not.

Input The first line of the input contains a single integers T, which denotes the number of testcases. The first line of each testcase contains a single integer n, which denotes the number of instructions. The second line contains n space separated integers, which are all 0 or 1. Output For each testcase output either "Valid" or "Invalid", in a new line. Constraints 1≤T≤10 1≤n≤105 All instructions are either 0 or 1. Sample Input 2 5 1 1 0 0 1 5 1 0 0 1 1 Sample Output Valid Invalid My code include<stdio.h> int main() { int i,t,n; scanf("%d",&t); while(t--) { scanf("%d",&n); int a[n]; int popcount=0,pushcount=0,flag=1; for(i=0;i<n;i++) {="" scanf("%d",&a[i]);="" if(a[i]="=1)" {="" pushcount++;="" }="" else="" {="" popcount++;="" }="" if(popcount="">pushcount) { flag=0; } } if(flag==0) { printf("Invalid\n"); } else printf("Valid\n"); } return(0); }

asked 12 Feb, 12:50

suvra1234's gravatar image

accept rate: 0%

toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:


question asked: 12 Feb, 12:50

question was seen: 30 times

last updated: 12 Feb, 12:50