convert python to java online

Solutions on MaxInterview for convert python to java online by the best coders in the world

showing results for - "convert python to java online"
Luka
07 Feb 2017
1#include <bits/stdc++.h>
2using namespace std;
3 
4int main()
5{
6  int m,ans=INT_MAX,I=-1,J=-1;
7  cin>>m;
8  vector<vector<int>> mat(m,vector<int>());
9  cin.ignore();
10  for(int i=0;i<m;i++)
11  {
12    string s;
13    getline(cin,s);
14    istringstream ss(s);
15    while(ss)
16    {
17      string w;
18      ss>>w;
19      if(w=="") break;
20      mat[i].push_back(stoi(w));
21    }
22  }
23  int n=mat[0].size();
24  vector<vector<int>> Ans1(m,vector<int>(n,1));
25  vector<vector<int>> Ans2(m,vector<int>(n,1));
26  vector<vector<int>> Ans3(m,vector<int>(n,1));
27  vector<vector<int>> Ans4(m,vector<int>(n,1));
28 
29  for(int i=0;i<m-1;i++)
30  for(int j=0;j<mat[i].size();j++)
31  if(mat[i][j]==mat[i+1][j])
32    Ans1[i+1][j]=Ans1[i][j]+1;
33  
34  for(int i=0;i<m;i++)
35  for(int j=0;j<mat[i].size() -1;j++)
36  if(mat[i][j]==mat[i][j+1])
37    Ans2[i][j+1]=Ans2[i][j]+1;
38  
39  for(int i=0;i<m-1;i++)
40  for(int j=0;j<mat[i].size()-1;j++)
41  if(mat[i][j]==mat[i+1][j+1])
42    Ans3[i+1][j+1]=Ans3[i][j]+1;
43 
44  for(int i=0;i<m-1;i++)
45  for(int j=1;j<mat[i].size();j++)
46  if(mat[i][j]==mat[i+1][j-1])
47    Ans4[i+1][j-1]=Ans4[i][j]+1;
48  
49  for(int i=0;i<m;i++)
50  for(int j=0;j<mat[i].size();j++)
51  {
52    if(Ans1[i][j]>=4 && ans>mat[i][j])
53    {ans=mat[i][j];I=i;J=j;}
54    if(Ans2[i][j]>=4 && ans>mat[i][j])
55    {ans=mat[i][j];I=i;J=j;}
56    if(Ans3[i][j]>=4 && ans>mat[i][j])
57    {ans=mat[i][j];I=i;J=j;}
58    if(Ans3[i][j]>=4 && ans>mat[i][j])
59    {ans=mat[i][j];I=i;J=j;}
60  }
61  if(I==-1)cout<<-1;
62  else cout<<ans<<endl;
63  
64}
Dario
19 Nov 2016
1import check50
2import check50_java
3
4@check50.check()
5def book_exists():
6    """Book.java exists."""
7    check50.exists("Book.java")
8
9@check50.check(book_exists)
10def book_compiles():
11    """Book.java compiles."""
12    check50_java.compile("Book.java")
13
14@check50.check()
15def press_exists():
16    """Press.java exists."""
17    check50.exists("Press.java")
18
19@check50.check(press_exists)
20def press_compiles():
21    """Press.java compiles."""
22    check50_java.compile("Press.java")
23
24@check50.check()
25def vm_exists():
26    """VendingMachine.java exists."""
27    check50.exists("VendingMachine.java")
28
29@check50.check(vm_exists)
30def vm_compiles():
31    """VendingMachine.java compiles."""
32    check50_java.compile("VendingMachine.java")
similar questions
queries leading to this page
convert python to java online