`{"id":"d474ae1c-676b-4b6c-aa9d-9edbd22f0190","name":"Ishaan And Sticks","description":"Ishaan has a craving for sticks. He has N sticks. He observes that some of his sticks are of the same length, and thus he can make squares out of those.\r\nHe wants to know how big a square he can make using those sticks as sides. Since the number of sticks is large, he can't do that manually. Can you tell him the maximum area of the biggest square that can be formed?\r\nAlso, calculate how many such squares can be made using the sticks.\r\n","inputFormat":"Input is managed for you\r\n","outputFormat":"Output is managed for you\r\n","constraints":" 1 &lt;= N &lt;= 10^5\r\n1 &lt;= arr[i] &lt;= 10^3","sampleCode":{"cpp":{"code":"#include<bits/stdc++.h>\nusing namespace std;\n\nvector<int> solve(vector<int> arr) {\n //write your code here\n }\n \n int main() {\n int n;\n cin>>n;\n vector<int> arr(n);\n \n for (int i = 0; i < n; i++) {\n cin>>arr[i];\n }\n\n vector<int> ans = solve(arr);\n\n for (int val : ans) {\n cout<<val<<\" \";;\n }\n return 0;\n }"},"java":{"code":"import java.util.*;\r\nimport java.io.*;\r\n\r\npublic class Main {\r\n\r\n public static ArrayList<Integer> solve(int[]arr) {\r\n\r\n }\r\n\r\n public static void main(String[]args) {\r\n Scanner scn = new Scanner(System.in);\r\n int n = scn.nextInt();\r\n int[]arr = new int[n];\r\n\r\n for (int i = 0; i < n; i++) {\r\n arr[i] = scn.nextInt();\r\n }\r\n\r\n ArrayList<Integer>ans = solve(arr);\r\n\r\n for (int val : ans) {\r\n System.out.print(val + \" \");\r\n }\r\n }\r\n}"},"python":{"code":""}},"points":10,"difficulty":"easy","sampleInput":"10\r\n3 3 4 4 3 4 3 1 4 2","sampleOutput":"16 1","questionVideo":"","hints":[],"associated":[],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"cb36811c-9cd7-4d80-aa52-ae9b8409862a","name":"Searching And Sorting For Intermediate","slug":"searching-and-sorting-for-intermediate-10001","type":0},{"id":"a3c9ef14-3f40-4037-8209-736984d3564f","name":"Ishaan And Sticks","slug":"ishaan-and-sticks","type":1}],"next":{"id":"170cd655-8742-4dff-8dde-a102f430d5b3","name":"Ishaan And Sticks","type":3,"slug":"ishaan-and-sticks"},"prev":{"id":"e9ee3c89-902a-4cc3-b498-4cb6a2217160","name":"First Bad Version","type":3,"slug":"first-bad-version"}}}`

# Ishaan And Sticks

Ishaan has a craving for sticks. He has N sticks. He observes that some of his sticks are of the same length, and thus he can make squares out of those. He wants to know how big a square he can make using those sticks as sides. Since the number of sticks is large, he can't do that manually. Can you tell him the maximum area of the biggest square that can be formed? Also, calculate how many such squares can be made using the sticks.

`{"id":"d474ae1c-676b-4b6c-aa9d-9edbd22f0190","name":"Ishaan And Sticks","description":"Ishaan has a craving for sticks. He has N sticks. He observes that some of his sticks are of the same length, and thus he can make squares out of those.\r\nHe wants to know how big a square he can make using those sticks as sides. Since the number of sticks is large, he can't do that manually. Can you tell him the maximum area of the biggest square that can be formed?\r\nAlso, calculate how many such squares can be made using the sticks.\r\n","inputFormat":"Input is managed for you\r\n","outputFormat":"Output is managed for you\r\n","constraints":" 1 &lt;= N &lt;= 10^5\r\n1 &lt;= arr[i] &lt;= 10^3","sampleCode":{"cpp":{"code":"#include<bits/stdc++.h>\nusing namespace std;\n\nvector<int> solve(vector<int> arr) {\n //write your code here\n }\n \n int main() {\n int n;\n cin>>n;\n vector<int> arr(n);\n \n for (int i = 0; i < n; i++) {\n cin>>arr[i];\n }\n\n vector<int> ans = solve(arr);\n\n for (int val : ans) {\n cout<<val<<\" \";;\n }\n return 0;\n }"},"java":{"code":"import java.util.*;\r\nimport java.io.*;\r\n\r\npublic class Main {\r\n\r\n public static ArrayList<Integer> solve(int[]arr) {\r\n\r\n }\r\n\r\n public static void main(String[]args) {\r\n Scanner scn = new Scanner(System.in);\r\n int n = scn.nextInt();\r\n int[]arr = new int[n];\r\n\r\n for (int i = 0; i < n; i++) {\r\n arr[i] = scn.nextInt();\r\n }\r\n\r\n ArrayList<Integer>ans = solve(arr);\r\n\r\n for (int val : ans) {\r\n System.out.print(val + \" \");\r\n }\r\n }\r\n}"},"python":{"code":""}},"points":10,"difficulty":"easy","sampleInput":"10\r\n3 3 4 4 3 4 3 1 4 2","sampleOutput":"16 1","questionVideo":"","hints":[],"associated":[],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"cb36811c-9cd7-4d80-aa52-ae9b8409862a","name":"Searching And Sorting For Intermediate","slug":"searching-and-sorting-for-intermediate-10001","type":0},{"id":"a3c9ef14-3f40-4037-8209-736984d3564f","name":"Ishaan And Sticks","slug":"ishaan-and-sticks","type":1}],"next":{"id":"170cd655-8742-4dff-8dde-a102f430d5b3","name":"Ishaan And Sticks","type":3,"slug":"ishaan-and-sticks"},"prev":{"id":"e9ee3c89-902a-4cc3-b498-4cb6a2217160","name":"First Bad Version","type":3,"slug":"first-bad-version"}}}`

Editor

# Ishaan And Sticks

easy

Ishaan has a craving for sticks. He has N sticks. He observes that some of his sticks are of the same length, and thus he can make squares out of those. He wants to know how big a square he can make using those sticks as sides. Since the number of sticks is large, he can't do that manually. Can you tell him the maximum area of the biggest square that can be formed? Also, calculate how many such squares can be made using the sticks.

## Constraints

1 <= N <= 10^5 1 <= arr[i] <= 10^3

## Format

### Input

Input is managed for you

### Output

Output is managed for you

## Example

Sample Input

```.css-23h8hz{color:inherit;font-size:0.875rem;line-height:1.125rem;letter-spacing:0.016rem;font-weight:var(--chakra-fontWeights-normal);white-space:pre-wrap;}10 3 3 4 4 3 4 3 1 4 2```

### Sample Output

`.css-3oaykw{color:var(--chakra-colors-active-primary);font-size:0.875rem;line-height:1.125rem;letter-spacing:0.016rem;font-weight:var(--chakra-fontWeights-normal);white-space:pre-wrap;font-family:Monospace;}16 1`

Discussions

Show Discussion

Related Resources